Commit Graph

21 Commits

Author SHA1 Message Date
George Kiagiadakis
ae7bed5655 log: make the level name a plain character in the log_level_info struct 2023-05-19 11:04:56 +03:00
George Kiagiadakis
cbf0d7284a log: make debug level 0 enable fatal errors
We always want to show fatal errors
2023-05-19 10:58:31 +03:00
George Kiagiadakis
3034fc7c79 log: accept 0 as a level and do safety checks on the level string 2023-05-19 10:50:46 +03:00
George Kiagiadakis
4f27d18bd3 log: rename "message" level to "notice" and print criticals with "E"
Syslog calls this level "notice" and I prefer it because we use it
to display significant messages that are not warnings, but they
are not really "standard", as GLib wants them to be. There is nothing
"standard" about log messages in general.

Also, make these notice messages be enabled at debug level 2, together
with warnings. The default log.level is 2 and it is a good idea to show
notices by default too.

Finally, show them in the log with "N" and also change criticals to be
shown with "E", meaning "error"... Then promote G_LOG_LEVEL_ERROR
messages to be shown with "F", meaning "fatal", because in fact these
messages are always fatal and always call abort(). Still, keep the term
"critical" in the functions to make sure that whoever uses them is aware
that this level is only for critical conditions and not suitable to
display any kind of error.
2023-05-18 16:19:49 +03:00
George Kiagiadakis
89c31d8190 log: disable "conn.*" topic by default, like pipewire does
This topic contains traces to debug the pipewire socket protocol.
Adding this pattern allows WIREPLUMBER_DEBUG=5 to show everything
except this trace by default, which is a more reasonable amount
of trace. To enable it, it must be explicitly specified in the
WIREPLUMBER_DEBUG env variable.
2023-05-18 15:53:50 +03:00
George Kiagiadakis
17b893c266 log: always set PIPEWIRE_DEBUG 2023-05-18 13:10:13 +03:00
George Kiagiadakis
b7e4654da4 log: rename log_level_index to level_index_from_flags, for consistency 2023-05-18 13:04:33 +03:00
George Kiagiadakis
dc548a3259 log: improve the initialization process
* initialize all log-related features in a new wp_log_init() function
* remove the ability to change the log patterns later, as the log
  topics are not referenced by the log system and there is no way to
  re-initialize them with different levels (we can still implement this
  in the future, if necessary, though)
* introduce the notion of a "global log level", referenced by all topics,
  and make the topics know if they have a custom level or not, like in
  pipewire; this is necessary to be able to set the level in the config
  file, which is read later by pw_context / WpCore.
2023-05-18 12:50:52 +03:00
George Kiagiadakis
4736d56557 log: implement a log topics system, like pipewire
The intention is to make checks for enabled log topics faster.

Every topic has its own structure that is statically defined in the file
where the logs are printed from. The structure is initialized transparently
when it is first used and it contains all the log level flags for the levels
that this topic should print messages. It is then checked on the wp_log()
macro before printing the message.

Topics from SPA/PipeWire are also handled natively, so messages are printed
directly without checking if the topic is enabled, since the PipeWire and SPA
macros do the checking themselves.

Messages coming from GLib are checked inside the handler.

An internal WpLogFields object is used to manage the state of each log
message, populating all the fields appropriately from the place they
are coming from (wp_log, spa_log, glib log), formatting the message and
then printing it. For printing to the journald, we still use the glib
message handler, converting all the needed fields to GLogField on demand.
That message handler does not do any checks for the topic or the level, so
we can just call it to send the message.
2023-05-16 20:42:28 +03:00
George Kiagiadakis
e908b93f3b log: describe the syslog priority numbers for code clarity 2023-05-16 16:46:43 +03:00
George Kiagiadakis
67f1eb585f log: implement different debug level per topic, like in pipewire 2023-04-25 08:50:13 +03:00
George Kiagiadakis
0fa484ac55 log: map spa ERROR and WARN to GLib's CRITICAL and WARNING respectively
Previously we were mapping SPA ERROR to GLib WARNING and
SPA WARN to GLib MESSAGE, which has been causing some confusion.

After some careful consideration, it makes sense to change that and
leave the GLib MESSAGE level as something to be avoided. With that
change, WIREPLUMBER_DEBUG=M will still enable the MESSAGE level,
but WIREPLUMBER_DEBUG=2 will only enable the WARN level and it will
take WIREPLUMBER_DEBUG=3 to enable both the INFO and MESSAGE levels.
2023-04-25 08:50:13 +03:00
George Kiagiadakis
5412ca972f log: guard against NULL messages
if for any reason the message field is NULL, replace it with the string
"(null)" and keep going... this avoids crashing the journald logger

Fixes #124
2021-12-20 17:54:14 +02:00
Peter Hutterer
5ec2138a72 log: support strings as level selectors in WIREPLUMBER_DEBUG
This allows for WIREPLUMBER_DEBUG="D" which avoids users having to
remember which numerical value the various levels have. The strings to
select are the ones printed by the logger, i.e. UECWMIDT.
2021-11-18 12:17:19 +00:00
Pauli Virtanen
fbb66cc290 wp: implement topics in SPA log interface
Implement SPA log topic API, showing log topics as GLIB_DOMAIN,
and enabling based on WIREPLUMBER_DEBUG.
2021-10-14 23:40:59 +03:00
Wim Taymans
fb28b076a1 Revert "wp: fix spa_log_methods version"
This reverts commit 86eecfc7e1.

The logger now correctly calls the old implementation when the new
method is not implemented.
2021-10-07 10:17:15 +02:00
Pauli Virtanen
86eecfc7e1 wp: fix spa_log_methods version
Wireplumber implements version 0 of spa_log methods. Fixes logging on
current pipewire.
2021-10-04 07:00:28 +00:00
Jason Francis
ed8346e77d docs: Add brief descriptions to all functions
This ensures all of these functions are picked up by g-ir-scanner.
2021-06-02 17:38:34 +00:00
George Kiagiadakis
b812e912d2 docs: fix C API documentation to work nicely with doxygen & sphinx 2021-05-25 14:19:53 +03:00
Raghavendra
d692f06f0d docs: api: Replace hotdoc specific commands with Doxygen specific commands 2021-05-25 14:19:53 +03:00
George Kiagiadakis
257d5cba47 wp: rename debug.{h,c} to log.{h,c}
Also rename the intermediate lua api table WpDebug -> WpLog

Keeps things more consistent with the function names (wp_log*),
with the lua api (Log.*) and with pipewire using log.{h,c} as well.
After all, these functions are for logging...
2021-05-06 15:50:07 +03:00