PipeWire: Logging

PipeWire 1.4.7

Loading...
Searching...
No Matches
Logging
Utilities

Logging functions of PipeWire. More...

## Files
file | log.h
| pipewire/log.h

## Macros
#define | PW_LOG_TOPIC_DEFINE_STATIC(var, topic)
| Define a static spa_log_topic and its constructor/destructor functions.
#define | PW_LOG_TOPIC_STATIC(var, topic)
| Declare a static log topic named var.
#define | PW_LOG_TOPIC_EXTERN(var)
| Declare a static log topic named var.
#define | PW_LOG_TOPIC(var, topic)
| Declare a static log topic named var.
#define | PW_LOG_TOPIC_INIT(var)
#define | pw_log_level_enabled(lev)
| Check if a loglevel is enabled.
#define | pw_log_topic_enabled(lev, t)
#define | pw_log_topic_custom_enabled(lev, t)
#define | pw_logtv(lev, topic, fmt, ap)
#define | pw_logt(lev, topic, ...)
#define | pw_log(lev, ...)
#define | pw_log_error(...)
#define | pw_log_warn(...)
#define | pw_log_info(...)
#define | pw_log_debug(...)
#define | pw_log_trace(...)
#define | pw_logt_error(t, ...)
#define | pw_logt_warn(t, ...)
#define | pw_logt_info(t, ...)
#define | pw_logt_debug(t, ...)
#define | pw_logt_trace(t, ...)
#define | pw_log_trace_fp(...)

## Functions
void | pw_log_set (struct spa_log *log)
| Configure a logging module.
struct spa_log * | pw_log_get (void)
| Get the log interface.
void | pw_log_set_level (enum spa_log_level level)
| Configure the logging level.
int | pw_log_set_level_string (const char *str)
| Configure the logging level using a string in PIPEWIRE_DEBUG format.
void | pw_log_logt (enum spa_log_level level, const struct spa_log_topic *topic, const char *file, int line, const char *func, const char *fmt,...)
| Log a message for a topic.
void | pw_log_logtv (enum spa_log_level level, const struct spa_log_topic *topic, const char *file, int line, const char *func, const char *fmt, va_list args)
| Log a message for a topic.
void | pw_log_log (enum spa_log_level level, const char *file, int line, const char *func, const char *fmt,...)
| Log a message for the default topic.
void | pw_log_logv (enum spa_log_level level, const char *file, int line, const char *func, const char *fmt, va_list args)
| Log a message for the default topic.
void | pw_log_topic_register (struct spa_log_topic *t)
| Register log topic with the logger, to enable dynamic log levels.
void | pw_log_topic_unregister (struct spa_log_topic *t)
| Unregister log topic.

## Variables
enum spa_log_level | pw_log_level
| The global log level.
struct spa_log_topic *const | PW_LOG_TOPIC_DEFAULT

## Detailed Description

Logging functions of PipeWire.

Logging is performed to stdout and stderr. Trace logging is performed in a lockfree ringbuffer and written out from the main thread as to not block the realtime threads.

## Macro Definition Documentation

## ◆ PW_LOG_TOPIC_DEFINE_STATIC

#define PW_LOG_TOPIC_DEFINE_STATIC | ( |  | var,
|  |  | topic )

Define a static spa_log_topic and its constructor/destructor functions.

Since
  1.1.0

## ◆ PW_LOG_TOPIC_STATIC

#define PW_LOG_TOPIC_STATIC | ( |  | var,
|  |  | topic )

Declare a static log topic named var.

The usual usage is:

PW_LOG_TOPIC_STATIC(my_topic);
#define PW_LOG_TOPIC_DEFAULT my_topic
void foo() {
pw_log_debug("bar");
}
PW_LOG_TOPIC_STATIC
#define PW_LOG_TOPIC_STATIC(var, topic)
Declare a static log topic named var.
Definition log.h:113
pw_log_debug
#define pw_log_debug(...)
Definition log.h:181

This macro also emits GCC attribute constructor/destructor functions that automatically call pw_log_topic_register/unregister.

## ◆ PW_LOG_TOPIC_EXTERN

#define PW_LOG_TOPIC_EXTERN | ( |  | var | ) |

Value:
extern struct spa_log_topic * const var
spa_log_topic
Identifier for a topic.
Definition log.h:93

Declare a static log topic named var.

See PW_LOG_TOPIC_STATIC for an example usage.

## ◆ PW_LOG_TOPIC

#define PW_LOG_TOPIC | ( |  | var,
|  |  | topic )

Declare a static log topic named var.

See PW_LOG_TOPIC_STATIC for an example usage.

## ◆ PW_LOG_TOPIC_INIT

#define PW_LOG_TOPIC_INIT | ( |  | var | ) |

Value:
spa_log_topic_init(pw_log_get(), var);
pw_log_get
struct spa_log * pw_log_get(void)
Get the log interface.
Definition log.c:216
spa_log_topic_init
SPA_API_LOG void spa_log_topic_init(struct spa_log *log, struct spa_log_topic *topic)
Definition log.h:238

## ◆ pw_log_level_enabled

#define pw_log_level_enabled | ( |  | lev | ) |

Value:
(pw_log_level >= (lev))
pw_log_level
enum spa_log_level pw_log_level
The global log level.
Definition log.c:25

Check if a loglevel is enabled.

## ◆ pw_log_topic_enabled

#define pw_log_topic_enabled | ( |  | lev,
|  |  | t )

Value:
((t) && (t)->has_custom_level ? (t)->level >= (lev) : pw_log_level_enabled((lev)))
pw_log_level_enabled
#define pw_log_level_enabled(lev)
Check if a loglevel is enabled.
Definition log.h:158

## ◆ pw_log_topic_custom_enabled

#define pw_log_topic_custom_enabled | ( |  | lev,
|  |  | t )

Value:
((t) && (t)->has_custom_level && (t)->level >= (lev))

## ◆ pw_logtv

#define pw_logtv | ( |  | lev,
|  |  | topic,
|  |  | fmt,
|  |  | ap )

## ◆ pw_logt

#define pw_logt | ( |  | lev,
|  |  | topic,
|  |  | ... )

## ◆ pw_log

#define pw_log | ( |  | lev,
|  |  | ... )

Value:
pw_logt(lev,PW_LOG_TOPIC_DEFAULT,__VA_ARGS__)
PW_LOG_TOPIC_DEFAULT
struct spa_log_topic *const PW_LOG_TOPIC_DEFAULT
Definition log.c:30
pw_logt
#define pw_logt(lev, topic,...)
Definition log.h:170

## ◆ pw_log_error

#define pw_log_error | ( |  | ... | ) |

Value:
pw_log(SPA_LOG_LEVEL_ERROR,__VA_ARGS__)
pw_log
#define pw_log(lev,...)
Definition log.h:176
SPA_LOG_LEVEL_ERROR
@ SPA_LOG_LEVEL_ERROR
Definition log.h:57

Examples
  bluez-session.c, export-sink.c, export-source.c, export-spa-device.c, export-spa.c, video-dsp-play.c, video-src-alloc.c, video-src-fixate.c, and video-src-reneg.c.

## ◆ pw_log_warn

#define pw_log_warn | ( |  | ... | ) |

Value:
pw_log(SPA_LOG_LEVEL_WARN,__VA_ARGS__)
SPA_LOG_LEVEL_WARN
@ SPA_LOG_LEVEL_WARN
Definition log.h:58

Examples
  audio-capture.c, audio-src-ring.c, audio-src-ring2.c, audio-src.c, bluez-session.c, tutorial4.c, tutorial5.c, video-dsp-play.c, video-dsp-src.c, video-play-fixate.c, video-play-pull.c, video-play-reneg.c, video-play.c, video-src-alloc.c, video-src-fixate.c, video-src-reneg.c, and video-src.c.

## ◆ pw_log_info

#define pw_log_info | ( |  | ... | ) |

Value:
pw_log(SPA_LOG_LEVEL_INFO,__VA_ARGS__)
SPA_LOG_LEVEL_INFO
@ SPA_LOG_LEVEL_INFO
Definition log.h:59

Examples
  midi-src.c, video-dsp-src.c, video-play-fixate.c, video-play-reneg.c, video-src-alloc.c, video-src-fixate.c, and video-src-reneg.c.

## ◆ pw_log_debug

#define pw_log_debug | ( |  | ... | ) |

Value:
pw_log(SPA_LOG_LEVEL_DEBUG,__VA_ARGS__)
SPA_LOG_LEVEL_DEBUG
@ SPA_LOG_LEVEL_DEBUG
Definition log.h:60

Examples
  bluez-session.c, export-source.c, and video-play.c.

## ◆ pw_log_trace

#define pw_log_trace | ( |  | ... | ) |

Value:
pw_log(SPA_LOG_LEVEL_TRACE,__VA_ARGS__)
SPA_LOG_LEVEL_TRACE
@ SPA_LOG_LEVEL_TRACE
Definition log.h:61

Examples
  audio-dsp-filter.c, audio-dsp-src.c, export-source.c, midi-src.c, video-dsp-play.c, video-dsp-src.c, video-play-pull.c, video-play.c, video-src-alloc.c, video-src-fixate.c, video-src-reneg.c, and video-src.c.

## ◆ pw_logt_error

#define pw_logt_error | ( |  | t,
|  |  | ... )

Value:
pw_logt(SPA_LOG_LEVEL_ERROR,t,__VA_ARGS__)

## ◆ pw_logt_warn

#define pw_logt_warn | ( |  | t,
|  |  | ... )

Value:
pw_logt(SPA_LOG_LEVEL_WARN,t,__VA_ARGS__)

## ◆ pw_logt_info

#define pw_logt_info | ( |  | t,
|  |  | ... )

Value:
pw_logt(SPA_LOG_LEVEL_INFO,t,__VA_ARGS__)

## ◆ pw_logt_debug

#define pw_logt_debug | ( |  | t,
|  |  | ... )

Value:
pw_logt(SPA_LOG_LEVEL_DEBUG,t,__VA_ARGS__)

## ◆ pw_logt_trace

#define pw_logt_trace | ( |  | t,
|  |  | ... )

Value:
pw_logt(SPA_LOG_LEVEL_TRACE,t,__VA_ARGS__)

## ◆ pw_log_trace_fp

#define pw_log_trace_fp | ( |  | ... | ) |

Value:
pw_log(SPA_LOG_LEVEL_TRACE,__VA_ARGS__)

## Function Documentation

## ◆ pw_log_set()

void pw_log_set | ( | struct spa_log * | log | ) |

Configure a logging module.

This is usually done automatically in pw_init() but you can install a custom logger before calling pw_init().

Configure a logging module.

Parameters

  log | the global log to set

## ◆ pw_log_get()

struct spa_log * pw_log_get | ( | void |  | ) |

Get the log interface.

Get the log interface.

Returns
  the global log

## ◆ pw_log_set_level()

void pw_log_set_level | ( | enum spa_log_level | level | ) |

Configure the logging level.

Configure the logging level.

Parameters

  level | the new log level

## ◆ pw_log_set_level_string()

int pw_log_set_level_string | ( | const char * | str | ) |

Configure the logging level using a string in PIPEWIRE_DEBUG format.

Since
  1.1.0

## ◆ pw_log_logt()

void pw_log_logt | ( | enum spa_log_level | level,
|  | const struct spa_log_topic * | topic,
|  | const char * | file,
|  | int | line,
|  | const char * | func,
|  | const char * | fmt,
|  |  | ... )

Log a message for a topic.

Log a message for a topic.

Parameters

  level | the log level
  topic | the topic
  file | the file this message originated from
  line | the line number
  func | the function
  fmt | the printf style format
  ... | printf style arguments to log

## ◆ pw_log_logtv()

void pw_log_logtv | ( | enum spa_log_level | level,
|  | const struct spa_log_topic * | topic,
|  | const char * | file,
|  | int | line,
|  | const char * | func,
|  | const char * | fmt,
|  | va_list | args )

Log a message for a topic.

Log a message for a topic.

Parameters

  level | the log level
  topic | the topic
  file | the file this message originated from
  line | the line number
  func | the function
  fmt | the printf style format
  args | a va_list of arguments

## ◆ pw_log_log()

void pw_log_log | ( | enum spa_log_level | level,
|  | const char * | file,
|  | int | line,
|  | const char * | func,
|  | const char * | fmt,
|  |  | ... )

Log a message for the default topic.

Parameters

  level | the log level
  file | the file this message originated from
  line | the line number
  func | the function
  fmt | the printf style format
  ... | printf style arguments to log

## ◆ pw_log_logv()

void pw_log_logv | ( | enum spa_log_level | level,
|  | const char * | file,
|  | int | line,
|  | const char * | func,
|  | const char * | fmt,
|  | va_list | args )

Log a message for the default topic.

Log a message for the default topic.

Parameters

  level | the log level
  file | the file this message originated from
  line | the line number
  func | the function
  fmt | the printf style format
  args | a va_list of arguments

## ◆ pw_log_topic_register()

void pw_log_topic_register | ( | struct spa_log_topic * | t | ) |

Register log topic with the logger, to enable dynamic log levels.

Topic must be unregistered before freeing it or plugin unload. May be used instead of PW_LOG_TOPIC_INIT This function is threadsafe.

Since
  1.1.0

## ◆ pw_log_topic_unregister()

void pw_log_topic_unregister | ( | struct spa_log_topic * | t | ) |

Unregister log topic.

This function is threadsafe.

Since
  1.1.0

## Variable Documentation

## ◆ pw_log_level

enum spa_log_level pw_log_level
| extern

The global log level.

## ◆ PW_LOG_TOPIC_DEFAULT

struct spa_log_topic* const PW_LOG_TOPIC_DEFAULT
| extern