Debug Logging¶
-
enum
wplog::
WpLogTopicFlags
¶ WpLogTopic flags.
Values:
-
WP_LOG_TOPIC_LEVEL_MASK
= 0xFFFF¶ the lower 16 bits of the flags are GLogLevelFlags
-
WP_LOG_TOPIC_FLAG_STATIC
= 1u << 30¶ the log topic has infinite lifetime (lives on static storage)
-
WP_LOG_TOPIC_FLAG_INITIALIZED
= 1u << 31¶ the log topic has been initialized
-
-
const guint
WP_LOG_LEVEL_TRACE
= (1 << 8)¶ A custom GLib log level for trace messages (extension of GLogLevelFlags)
-
void
wp_log_topic_register
(WpLogTopic * topic)¶ Registers a log topic.
The log topic must be unregistered using wp_log_topic_unregister before its lifetime ends.
This function is threadsafe.
-
void
wp_log_topic_unregister
(WpLogTopic * topic)¶ Unregisters a log topic.
This function is threadsafe.
-
void
wp_log_topic_init
(WpLogTopic * topic)¶ Initializes a log topic. Internal function, don’t use it directly.
-
GLogWriterOutput
wp_log_writer_default
(GLogLevelFlags log_level_flags, const GLogField * fields, gsize n_fields, gpointer user_data)¶ WirePlumber’s GLogWriterFunc.
This is installed automatically when you call wp_init() with WP_INIT_SET_GLIB_LOG set in the flags
-
void
wp_log_checked
(const gchar * log_topic, GLogLevelFlags log_level_flags, const gchar * file, const gchar * line, const gchar * func, GType object_type, gconstpointer object, const gchar * message_format, ...)¶ Used internally by the debug logging macros. Avoid using it directly.
This assumes that the arguments are correct and that the log_topic is enabled for the given log_level. No additional checks are performed.
-
struct spa_log*
wp_spa_log_get_instance
(void)¶ Gets WirePlumber’s instance of
spa_log
- Return
WirePlumber’s instance of
spa_log
, which can be used to redirect PipeWire’s log messages to the currently installed GLogWriterFunc. This is installed automatically when you call wp_init() with WP_INIT_SET_PW_LOG set in the flags
-
WP_DEFINE_LOCAL_LOG_TOPIC
(name) WP_LOG_TOPIC_STATIC(WP_LOCAL_LOG_TOPIC, name)¶ Defines a static WpLogTopic* variable called WP_LOCAL_LOG_TOPIC.
The log topic is automatically intialized to the given topic name when it is first used. The default logging macros expect this variable to be defined, so it is a good coding practice in the WirePlumber codebase to start all files at the top with:
WP_DEFINE_LOCAL_LOG_TOPIC ("some-topic")
- Parameters
name
: The name of the log topic
-
WP_LOG_TOPIC_STATIC
(var, name) static WpLogTopic var##_struct = { .topic_name = name, .flags = WP_LOG_TOPIC_FLAG_STATIC }; \ static G_GNUC_UNUSED WpLogTopic * var = &(var##_struct);¶ Defines a static WpLogTopic* variable called var with the given topic name.
- Parameters
var
: The name of the variable to definename
: The name of the log topic
-
WP_LOG_TOPIC
(var, name) WpLogTopic var##_struct = { .topic_name = name, .flags = WP_LOG_TOPIC_FLAG_STATIC }; \ WpLogTopic * var = &(var##_struct);¶ Defines a WpLogTopic* variable called var with the given topic name. Unlike WP_LOG_TOPIC_STATIC(), the variable defined here is not static, so it can be linked to by other object files.
- Parameters
var
: The name of the variable to definename
: The name of the log topic
-
WP_LOG_TOPIC_EXTERN
(var) extern WpLogTopic * var;¶ Declares an extern WpLogTopic* variable called var. This variable is meant to be defined in a .c file with WP_LOG_TOPIC()
- Parameters
var
: The name of the variable to declare
-
WP_OBJECT_FORMAT
“<%s:%p>”¶ A format string to print GObjects with WP_OBJECT_ARGS() For example:
GObject *myobj = ...; wp_debug ("This: " WP_OBJECT_FORMAT " is an object", WP_OBJECT_ARGS (myobj));
-
WP_OBJECT_ARGS
(object) (object ? G_OBJECT_TYPE_NAME(object) : “invalid”), object¶ A macro to format an object for printing with WP_OBJECT_FORMAT.
-
wp_critical
(...) wp_log (WP_LOCAL_LOG_TOPIC, G_LOG_LEVEL_CRITICAL, 0, NULL, __VA_ARGS__)¶ Logs a critical message to the standard log via GLib’s logging system.
- Parameters
...
: A format string, followed by format arguments in printf() style
-
wp_critical_object
(object, ...) wp_log (WP_LOCAL_LOG_TOPIC, G_LOG_LEVEL_CRITICAL, (object) ? G_TYPE_FROM_INSTANCE (object) : G_TYPE_NONE, object, __VA_ARGS__)¶ Logs a critical message to the standard log via GLib’s logging system.
- Parameters
object
: A GObject associated with the log; this is printed in a special way to make it easier to track messages from a specific object...
: A format string, followed by format arguments in printf() style
-
wp_critical_boxed
(type, object, ...) wp_log (WP_LOCAL_LOG_TOPIC, G_LOG_LEVEL_CRITICAL, type, object, __VA_ARGS__)¶ Logs a critical message to the standard log via GLib’s logging system.
- Parameters
type
: The type of objectobject
: A boxed object associated with the log; this is printed in a special way to make it easier to track messages from a specific object. For some object types, contents from the object are also printed (ex WpSpaPod)...
: A format string, followed by format arguments in printf() style
-
wp_warning
(...) wp_log (WP_LOCAL_LOG_TOPIC, G_LOG_LEVEL_WARNING, 0, NULL, __VA_ARGS__)¶ Logs a warning message to the standard log via GLib’s logging system.
- Parameters
...
: A format string, followed by format arguments in printf() style
-
wp_warning_object
(object, ...) wp_log (WP_LOCAL_LOG_TOPIC, G_LOG_LEVEL_WARNING, (object) ? G_TYPE_FROM_INSTANCE (object) : G_TYPE_NONE, object, __VA_ARGS__)¶ Logs a warning message to the standard log via GLib’s logging system.
- Parameters
object
: A GObject associated with the log; this is printed in a special way to make it easier to track messages from a specific object...
: A format string, followed by format arguments in printf() style
-
wp_warning_boxed
(type, object, ...) wp_log (WP_LOCAL_LOG_TOPIC, G_LOG_LEVEL_WARNING, type, object, __VA_ARGS__)¶ Logs a warning message to the standard log via GLib’s logging system.
- Parameters
type
: The type of objectobject
: A boxed object associated with the log; this is printed in a special way to make it easier to track messages from a specific object. For some object types, contents from the object are also printed (ex WpSpaPod)...
: A format string, followed by format arguments in printf() style
-
wp_notice
(...) wp_log (WP_LOCAL_LOG_TOPIC, G_LOG_LEVEL_MESSAGE, 0, NULL, __VA_ARGS__)¶ Logs a notice message to the standard log via GLib’s logging system.
- Parameters
...
: A format string, followed by format arguments in printf() style
-
wp_notice_object
(object, ...) wp_log (WP_LOCAL_LOG_TOPIC, G_LOG_LEVEL_MESSAGE, (object) ? G_TYPE_FROM_INSTANCE (object) : G_TYPE_NONE, object, __VA_ARGS__)¶ Logs a notice message to the standard log via GLib’s logging system.
- Parameters
object
: A GObject associated with the log; this is printed in a special way to make it easier to track messages from a specific object...
: A format string, followed by format arguments in printf() style
-
wp_notice_boxed
(type, object, ...) wp_log (WP_LOCAL_LOG_TOPIC, G_LOG_LEVEL_MESSAGE, type, object, __VA_ARGS__)¶ Logs a notice message to the standard log via GLib’s logging system.
- Parameters
type
: The type of objectobject
: A boxed object associated with the log; this is printed in a special way to make it easier to track messages from a specific object. For some object types, contents from the object are also printed (ex WpSpaPod)...
: A format string, followed by format arguments in printf() style
-
wp_info
(...) wp_log (WP_LOCAL_LOG_TOPIC, G_LOG_LEVEL_INFO, 0, NULL, __VA_ARGS__)¶ Logs a info message to the standard log via GLib’s logging system.
- Parameters
...
: A format string, followed by format arguments in printf() style
-
wp_info_object
(object, ...) wp_log (WP_LOCAL_LOG_TOPIC, G_LOG_LEVEL_INFO, (object) ? G_TYPE_FROM_INSTANCE (object) : G_TYPE_NONE, object, __VA_ARGS__)¶ Logs a info message to the standard log via GLib’s logging system.
- Parameters
object
: A GObject associated with the log; this is printed in a special way to make it easier to track messages from a specific object...
: A format string, followed by format arguments in printf() style
-
wp_info_boxed
(type, object, ...) wp_log (WP_LOCAL_LOG_TOPIC, G_LOG_LEVEL_INFO, type, object, __VA_ARGS__)¶ Logs a info message to the standard log via GLib’s logging system.
- Parameters
type
: The type of objectobject
: A boxed object associated with the log; this is printed in a special way to make it easier to track messages from a specific object. For some object types, contents from the object are also printed (ex WpSpaPod)...
: A format string, followed by format arguments in printf() style
-
wp_debug
(...) wp_log (WP_LOCAL_LOG_TOPIC, G_LOG_LEVEL_DEBUG, 0, NULL, __VA_ARGS__)¶ Logs a debug message to the standard log via GLib’s logging system.
- Parameters
...
: A format string, followed by format arguments in printf() style
-
wp_debug_object
(object, ...) wp_log (WP_LOCAL_LOG_TOPIC, G_LOG_LEVEL_DEBUG, (object) ? G_TYPE_FROM_INSTANCE (object) : G_TYPE_NONE, object, __VA_ARGS__)¶ Logs a debug message to the standard log via GLib’s logging system.
- Parameters
object
: A GObject associated with the log; this is printed in a special way to make it easier to track messages from a specific object...
: A format string, followed by format arguments in printf() style
-
wp_debug_boxed
(type, object, ...) wp_log (WP_LOCAL_LOG_TOPIC, G_LOG_LEVEL_DEBUG, type, object, __VA_ARGS__)¶ Logs a debug message to the standard log via GLib’s logging system.
- Parameters
type
: The type of objectobject
: A boxed object associated with the log; this is printed in a special way to make it easier to track messages from a specific object. For some object types, contents from the object are also printed (ex WpSpaPod)...
: A format string, followed by format arguments in printf() style
-
wp_trace
(...) wp_log (WP_LOCAL_LOG_TOPIC, WP_LOG_LEVEL_TRACE, 0, NULL, __VA_ARGS__)¶ Logs a trace message to the standard log via GLib’s logging system.
- Parameters
...
: A format string, followed by format arguments in printf() style
-
wp_trace_object
(object, ...) wp_log (WP_LOCAL_LOG_TOPIC, WP_LOG_LEVEL_TRACE, (object) ? G_TYPE_FROM_INSTANCE (object) : G_TYPE_NONE, object, __VA_ARGS__)¶ Logs a trace message to the standard log via GLib’s logging system.
- Parameters
object
: A GObject associated with the log; this is printed in a special way to make it easier to track messages from a specific object...
: A format string, followed by format arguments in printf() style
-
wp_trace_boxed
(type, object, ...) wp_log (WP_LOCAL_LOG_TOPIC, WP_LOG_LEVEL_TRACE, type, object, __VA_ARGS__)¶ Logs a trace message to the standard log via GLib’s logging system.
- Parameters
type
: The type of objectobject
: A boxed object associated with the log; this is printed in a special way to make it easier to track messages from a specific object. For some object types, contents from the object are also printed (ex WpSpaPod)...
: A format string, followed by format arguments in printf() style
-
wp_log
(topic, level, type, object, ...) ({ \ if (G_UNLIKELY (wp_log_topic_is_enabled (topic, level))) \ wp_log_checked (topic->topic_name, level, __FILE__, G_STRINGIFY (__LINE__), \ G_STRFUNC, type, object, __VA_ARGS__); \ })¶ The generic form of all the logging macros.
- Remark
Don’t use this directly, use one of the other logging macros
-
struct
WpLogTopic
¶ - #include <log.h>
A structure representing a log topic.