Commit graph

15 commits

Author SHA1 Message Date
Peter Hutterer 04d32ba794 test: fix a variable initialization
Technically valid since it's a null pointer but let's not do this.
2021-10-12 08:58:39 +00:00
Peter Hutterer 36c1917a16 test: use a function-specific token instead of a common one
This avoid false detections of the MARK token from other tetsts when
tests are run in parallel.
2021-10-12 08:58:39 +00:00
Peter Hutterer e7ac8adaa5 test: wait up to a second for our MARK message to appear in the journal
The previous code exposed a race condition, it assumed that our MARK
message was in the next lot of messages by the journal. If something
else would write to the journal in the meantime and our message took
time to arrive, the test would fail.

Fixes #1710
2021-10-12 08:58:39 +00:00
Peter Hutterer 6df8ce3031 test: fix a race condition with the journal test
The docs are slightly ambiguous here but it appears a call to
sd_journal_next() is required at least once before the actual data
message.

journalctl positions the cursor with sd_journal_seek_tail() followed by
sd_journal_seek_previous(). The actual enty is then fetched with
sd_journal_next().

Let's do the same here and let's hope this fixes the current race
condition with the test sometimes failing.
2021-10-11 07:23:38 +00:00
Peter Hutterer 52bd80aaa4 log: add topic loggers and a default topic
pw_log_log/logv now go through the topic-based logger using the
"default" topic. Log topics themselves can be allocated by the call
sites. The simplest way to use a topic from e.g. a module:

    PW_LOG_TOPIC_STATIC(mod_topic, "mod.foo");
    #define PW_LOG_TOPIC_DEFAULT mod_topic
    ...
    void pipewire__module_init() {
  	  PW_LOG_TOPIC_INIT(mod_topic);
  	  ...
    }

With the #define all pw_log_foo() are now routed through the custom
topic. For the cases where the log topic must be specified, a
pw_logt_foo() set of macros is available.

Log topics are enabled through the PIPEWIRE_DEBUG environment variable
which now supports globs, e.g. PIPEWIRE_DEBUG="*:I;mod.access:D"
to enable global INFO but DEBUG for the access module.

Namespaces documented are "pw", "mod" and "conn", for pipewire-internal
stuff, modules and connection dumping. The latter is special-cased to
avoid spamming the log files, it requires an expcit "conn.<glob>"
pattern to enable.

The "default" topic always exists and is the fallback for any
pw_log_foo() invocation that does not use a topic.
2021-09-28 09:35:38 +02:00
Peter Hutterer 59a5791d41 spa: implement the new topic logging for the provided loggers
Both simple log implementation now support the new topic-based
functions, and so does the journal logger too.
2021-09-28 09:35:38 +02:00
Peter Hutterer 2b65fb36f2 test: simplify the logger test a bit
The tests using this function use the pw_log* macros which invoke
whichever logger pipewire has set. Since the default logging
implementation supports logging to a file anyway, let's just use that
instead of having to load the plugin ourselves.
2021-09-24 12:33:02 +10:00
Peter Hutterer c6f0ac7ff0 test: fix the calls to pw_deinit()
Missing from some tests, superfluous in the other test because it was
already called in the test_log_levels() helper function
2021-09-22 12:15:35 +10:00
Peter Hutterer 48cff597a6 test: don't try to log for LOG_LEVEL_NONE
We can only log for a level below our current one if we are two above
NONE. And by the same instance, we don't expect NONE messages to show
up.
2021-09-22 12:15:34 +10:00
Peter Hutterer b00bc81929 test: fix a use-of-uninitialized-variable compiler warning
False positive, we abort in the cases where this isn't initialized.

Fixes e1672f9762
2021-09-22 12:15:33 +10:00
Peter Hutterer dfb40fb714 test: implement a test for the journal logger 2021-09-20 07:29:03 +00:00
Peter Hutterer e1672f9762 pipewire: allow for log level names in PIPEWIRE_DEBUG
Allow one of "XEWIDT" to refer to none, errors, warnings, info, debug
and trace, respectively because they're immediately recognizable. Well,
except maybe the X.

PIPEWIRE_DEBUG="I" is equivalent to PIPEWIRE_DEBUG="3" for example.
2021-09-10 07:38:20 +00:00
Peter Hutterer 0a21d76334 test: add tests for the log levels to show up correctly
Two tests, once with pw_log_set_level(), once with PIPEWIRE_DEBUG
2021-09-10 07:38:20 +00:00
Peter Hutterer 7240058bee test: add test for logger's ANSI escape sequences
Set up the logger with colors enabled but since our log file is not a tty,
this should not print any ansi sequences into the log.
2021-06-09 18:00:39 +10:00
Peter Hutterer 518ffde9ec test: add a test for the logger truncation
See c851349f17
2021-06-09 18:00:39 +10:00