Add a mechanism to emit level prefixes on diagnostic output
-
tests: Make simple assertions about capsule-capture-libs error messages
We don't enforce a specific error message, but we do assert that there's no output on stdout, and an error message prefixed with the program name on one of the lines of stderr.
-
utils: Add centralized logging functions
This will let us change the behaviour of all diagnostic messages at once, by changing only capsule_logv().
For now, the syslog-style severity is accepted but ignored. Subsequent commits will make use of this.
-
utils: Prepend basename of argv[0] to diagnostic messages
This allows them to be distinguished from messages logged by some other executable invoked around the same time, and makes
capsule_log( LOG_WARNING, ... )
a drop-in substitute forwarnx()
. -
utils: Add capsule_err(), capsule_warn() wrappers for capsule_log()
These mimic the behaviour of errx() and warnx(), but will benefit from future enhancements to capsule_log().
-
capture-libs: Put all logging through capsule_log() wrappers
In a couple of places this requires explicitly emitting the stringified value of errno, because we have equivalents of warnx() and errx(), but not warn() and err().
-
capture-libs: Add a --level-prefix option
This will allow the output of capsule-capture-libs (and in principle other tools) to be piped to a log handler such as
logger --prio-prefix
,systemd-cat --level-prefix=true
orsrt-logger --parse-level-prefix
which will filter or format the messages according to their severity.As currently implemented, fatal errors are emitted as LOG_ERR, warnings are LOG_WARNING, and all debug messages are LOG_DEBUG. A facility such as LOG_USER is not included: this is optional for logger(1), and not allowed for systemd-cat(1) and srt-logger.
steamrt/tasks#444
-
tests: Add a test for --level-prefix
Repeat the test-case where we produced an error message about a library having the wrong ABI, but this time, use --level-prefix and assert that we add the <3> prefix for a fatal error.
steamrt/tasks#444
-
Consistently add an error: or warning: prefix where appropriate
Previously we said "warning:" for about half the warnings, and didn't annotate fatal errors at all.
-
tests: Assert that we see a warning message where expected
-
capture-libs: Add a new flag to suppress warnings
Sometimes we find ourselves capturing a library for which the dependencies can legitimately be missing, for example
libnvidia-pkcs11.so.*
on Ubuntu 24.04 (which depends on OpenSSL 1.1, which Ubuntu no longer provides).This is really an OS bug (providing a library without its dependencies), and ideally Ubuntu should stop providing
libnvidia-pkcs11.so.*
(like Debian did), but it results in confusing messages that could make a user wrongly believe that it's the root cause of a genuine problem.steamrt/tasks#488
-
tests: Assert that "quiet:" works as intended
In a test that already emits a warning message, prepending "quiet:" to the pattern should de-escalate the warning to a debug message.
In a test that emits a fatal error, prepending "quiet:" to the pattern has no effect: it's still an error.
steamrt/tasks#488