PipeWire  0.3.38
SPA Logging

Data Structures

struct  spa_log
 
struct  spa_log_topic
 Identifier for a topic. More...
 
struct  spa_log_methods
 

Macros

#define SPA_LOG_IMPL_DEFINE(name)
 
#define SPA_LOG_IMPL_INIT(name)
 
#define SPA_LOG_IMPL(name)   SPA_LOG_IMPL_DEFINE(name) = SPA_LOG_IMPL_INIT(name)
 
#define SPA_LOG_TOPIC_DEFAULT   NULL
 The default log topic. More...
 
#define SPA_TYPE_INTERFACE_Log   SPA_TYPE_INFO_INTERFACE_BASE "Log"
 The Log interface. More...
 
#define SPA_LOG_TOPIC(v, t)   (struct spa_log_topic){ .version = v, .topic = (t)}
 
#define spa_log_topic_init(l, topic)
 
#define spa_log_level_enabled(l, lev)   ((l) && (l)->level >= (lev))
 
#define spa_log_level_topic_enabled(l, topic, lev)
 
#define spa_log_logt(l, lev, topic, ...)
 
#define spa_log_logtv(l, lev, topic, ...)
 
#define spa_log_log(l, lev, ...)   spa_log_logt(l,lev,SPA_LOG_TOPIC_DEFAULT,__VA_ARGS__)
 
#define spa_log_logv(l, lev, ...)   spa_log_logtv(l,lev,SPA_LOG_TOPIC_DEFAULT,__VA_ARGS__)
 
#define spa_log_error(l, ...)   spa_log_log(l,SPA_LOG_LEVEL_ERROR,__FILE__,__LINE__,__func__,__VA_ARGS__)
 
#define spa_log_warn(l, ...)   spa_log_log(l,SPA_LOG_LEVEL_WARN,__FILE__,__LINE__,__func__,__VA_ARGS__)
 
#define spa_log_info(l, ...)   spa_log_log(l,SPA_LOG_LEVEL_INFO,__FILE__,__LINE__,__func__,__VA_ARGS__)
 
#define spa_log_debug(l, ...)   spa_log_log(l,SPA_LOG_LEVEL_DEBUG,__FILE__,__LINE__,__func__,__VA_ARGS__)
 
#define spa_log_trace(l, ...)   spa_log_log(l,SPA_LOG_LEVEL_TRACE,__FILE__,__LINE__,__func__,__VA_ARGS__)
 
#define spa_logt_error(l, t, ...)   spa_log_logt(l,SPA_LOG_LEVEL_ERROR,t,__FILE__,__LINE__,__func__,__VA_ARGS__)
 
#define spa_logt_warn(l, t, ...)   spa_log_logt(l,SPA_LOG_LEVEL_WARN,t,__FILE__,__LINE__,__func__,__VA_ARGS__)
 
#define spa_logt_info(l, t, ...)   spa_log_logt(l,SPA_LOG_LEVEL_INFO,t,__FILE__,__LINE__,__func__,__VA_ARGS__)
 
#define spa_logt_debug(l, t, ...)   spa_log_logt(l,SPA_LOG_LEVEL_DEBUG,t,__FILE__,__LINE__,__func__,__VA_ARGS__)
 
#define spa_logt_trace(l, t, ...)   spa_log_logt(l,SPA_LOG_LEVEL_TRACE,t,__FILE__,__LINE__,__func__,__VA_ARGS__)
 
#define spa_log_trace_fp(l, ...)   spa_log_log(l,SPA_LOG_LEVEL_TRACE,__FILE__,__LINE__,__func__,__VA_ARGS__)
 
#define SPA_KEY_LOG_LEVEL   "log.level"
 keys can be given when initializing the logger handle More...
 
#define SPA_KEY_LOG_COLORS   "log.colors"
 enable colors in the logger More...
 
#define SPA_KEY_LOG_FILE   "log.file"
 log to the specified file instead of stderr. More...
 
#define SPA_KEY_LOG_TIMESTAMP   "log.timestamp"
 log timestamps More...
 
#define SPA_KEY_LOG_LINE   "log.line"
 log file and line numbers More...
 
#define SPA_KEY_LOG_PATTERNS   "log.patterns"
 Spa:String:JSON array of [ {"pattern" : level}, ... More...
 

Enumerations

enum  spa_log_level {
  SPA_LOG_LEVEL_NONE = 0, SPA_LOG_LEVEL_ERROR, SPA_LOG_LEVEL_WARN, SPA_LOG_LEVEL_INFO,
  SPA_LOG_LEVEL_DEBUG, SPA_LOG_LEVEL_TRACE
}
 

Functions

void spa_log_impl_logtv (void *object, 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)
 
void spa_log_impl_logt (void *object, enum spa_log_level level, const struct spa_log_topic *topic, const char *file, int line, const char *func, const char *fmt,...)
 
void spa_log_impl_logv (void *object, enum spa_log_level level, const char *file, int line, const char *func, const char *fmt, va_list args)
 
void spa_log_impl_log (void *object, enum spa_log_level level, const char *file, int line, const char *func, const char *fmt,...)
 
void spa_log_impl_topic_init (void *object, struct spa_log_topic *topic)
 

Detailed Description

Macro Definition Documentation

◆ SPA_KEY_LOG_COLORS

#define SPA_KEY_LOG_COLORS   "log.colors"

enable colors in the logger

◆ SPA_KEY_LOG_FILE

#define SPA_KEY_LOG_FILE   "log.file"

log to the specified file instead of stderr.

◆ SPA_KEY_LOG_LEVEL

#define SPA_KEY_LOG_LEVEL   "log.level"

keys can be given when initializing the logger handle

the default log level

◆ SPA_KEY_LOG_LINE

#define SPA_KEY_LOG_LINE   "log.line"

log file and line numbers

◆ SPA_KEY_LOG_PATTERNS

#define SPA_KEY_LOG_PATTERNS   "log.patterns"

Spa:String:JSON array of [ {"pattern" : level}, ...

]

◆ SPA_KEY_LOG_TIMESTAMP

#define SPA_KEY_LOG_TIMESTAMP   "log.timestamp"

log timestamps

◆ spa_log_debug

#define spa_log_debug (   l,
  ... 
)    spa_log_log(l,SPA_LOG_LEVEL_DEBUG,__FILE__,__LINE__,__func__,__VA_ARGS__)

◆ spa_log_error

#define spa_log_error (   l,
  ... 
)    spa_log_log(l,SPA_LOG_LEVEL_ERROR,__FILE__,__LINE__,__func__,__VA_ARGS__)

◆ SPA_LOG_IMPL

#define SPA_LOG_IMPL (   name)    SPA_LOG_IMPL_DEFINE(name) = SPA_LOG_IMPL_INIT(name)

◆ SPA_LOG_IMPL_DEFINE

#define SPA_LOG_IMPL_DEFINE (   name)
Value:
struct { \
struct spa_log log; \
const char * name
Definition: media-session.c:2394
Definition: x86_64-redhat-linux-gnu/doc/spa/support/log.h:72
Definition: x86_64-redhat-linux-gnu/doc/spa/support/log.h:106
struct spa_thread_utils_methods methods
Definition: thread.c:68

◆ SPA_LOG_IMPL_INIT

#define SPA_LOG_IMPL_INIT (   name)
Value:
SPA_CALLBACKS_INIT(&name.methods, &name) }, \
SPA_LOG_LEVEL_INFO, }, \
spa_log_impl_log, \
spa_log_impl_logv, \
spa_log_impl_logt, \
spa_log_impl_logtv, \
} }
const char * name
Definition: media-session.c:2394
#define SPA_VERSION_LOG_METHODS
Definition: x86_64-redhat-linux-gnu/doc/spa/support/log.h:107
#define SPA_TYPE_INTERFACE_Log
The Log interface.
Definition: x86_64-redhat-linux-gnu/doc/spa/support/log.h:69
#define SPA_VERSION_LOG
the version of this log.
Definition: x86_64-redhat-linux-gnu/doc/spa/support/log.h:75

◆ spa_log_info

#define spa_log_info (   l,
  ... 
)    spa_log_log(l,SPA_LOG_LEVEL_INFO,__FILE__,__LINE__,__func__,__VA_ARGS__)

◆ spa_log_level_enabled

#define spa_log_level_enabled (   l,
  lev 
)    ((l) && (l)->level >= (lev))

◆ spa_log_level_topic_enabled

#define spa_log_level_topic_enabled (   l,
  topic,
  lev 
)
Value:
({ \
struct spa_log *_log = l; \
enum spa_log_level _lev = _log ? _log->level : SPA_LOG_LEVEL_NONE; \
struct spa_log_topic *_t = (struct spa_log_topic *)topic; \
if (_t && _t->has_custom_level) \
_lev = _t->level; \
_lev >= lev; \
})
Identifier for a topic.
Definition: x86_64-redhat-linux-gnu/doc/spa/support/log.h:93
spa_log_level
Definition: x86_64-redhat-linux-gnu/doc/spa/support/log.h:57
Definition: x86_64-redhat-linux-gnu/doc/spa/support/log.h:58
#define _log(_c, fmt,...)
Definition: log.c:231
Definition: x86_64-redhat-linux-gnu/doc/spa/support/log.h:72
const char * topic
The string identifier for the topic.
Definition: x86_64-redhat-linux-gnu/doc/spa/support/log.h:99

◆ spa_log_log

#define spa_log_log (   l,
  lev,
  ... 
)    spa_log_logt(l,lev,SPA_LOG_TOPIC_DEFAULT,__VA_ARGS__)

◆ spa_log_logt

#define spa_log_logt (   l,
  lev,
  topic,
  ... 
)
Value:
({ \
struct spa_log *_l = l; \
struct spa_interface *_if = &_l->iface; \
_if, struct spa_log_methods, 1)) \
spa_interface_call(_if, \
struct spa_log_methods, logt, 1, \
lev, topic, \
__VA_ARGS__); \
struct spa_log_methods, log, 0, \
lev, __VA_ARGS__); \
} \
})
#define spa_interface_callback_version_min(iface, method_type, vers)
True if the iface's callbacks are of version vers, false otherwise.
Definition: hook.h:208
Definition: x86_64-redhat-linux-gnu/doc/spa/support/log.h:72
Definition: x86_64-redhat-linux-gnu/doc/spa/support/log.h:106
#define spa_interface_call(iface, method_type, method, vers,...)
Invoke method named method in the callbacks on the given interface object.
Definition: hook.h:216
Definition: hook.h:149
#define spa_log_level_topic_enabled(l, topic, lev)
Definition: x86_64-redhat-linux-gnu/doc/spa/support/log.h:229
#define SPA_UNLIKELY(x)
Definition: defs.h:242
const char * topic
The string identifier for the topic.
Definition: x86_64-redhat-linux-gnu/doc/spa/support/log.h:99

◆ spa_log_logtv

#define spa_log_logtv (   l,
  lev,
  topic,
  ... 
)
Value:
({ \
struct spa_log *_l = l; \
struct spa_interface *_if = &_l->iface; \
_if, struct spa_log_methods, 1)) \
spa_interface_call(_if, \
struct spa_log_methods, logtv, 1, \
lev, topic, \
__VA_ARGS__); \
struct spa_log_methods, logv, 0, \
lev, __VA_ARGS__); \
} \
})
#define spa_interface_callback_version_min(iface, method_type, vers)
True if the iface's callbacks are of version vers, false otherwise.
Definition: hook.h:208
Definition: x86_64-redhat-linux-gnu/doc/spa/support/log.h:72
Definition: x86_64-redhat-linux-gnu/doc/spa/support/log.h:106
#define spa_interface_call(iface, method_type, method, vers,...)
Invoke method named method in the callbacks on the given interface object.
Definition: hook.h:216
Definition: hook.h:149
#define spa_log_level_topic_enabled(l, topic, lev)
Definition: x86_64-redhat-linux-gnu/doc/spa/support/log.h:229
#define SPA_UNLIKELY(x)
Definition: defs.h:242
const char * topic
The string identifier for the topic.
Definition: x86_64-redhat-linux-gnu/doc/spa/support/log.h:99

Referenced by pw_log_logt(), and pw_log_logtv().

◆ spa_log_logv

#define spa_log_logv (   l,
  lev,
  ... 
)    spa_log_logtv(l,lev,SPA_LOG_TOPIC_DEFAULT,__VA_ARGS__)

◆ SPA_LOG_TOPIC

#define SPA_LOG_TOPIC (   v,
 
)    (struct spa_log_topic){ .version = v, .topic = (t)}

◆ SPA_LOG_TOPIC_DEFAULT

#define SPA_LOG_TOPIC_DEFAULT   NULL

The default log topic.

Redefine this in your code to allow for the spa_log_* macros to work correctly, e.g:

struct spa_log_topic *mylogger;
#undef SPA_LOG_TOPIC_DEFAULT
#define SPA_LOG_TOPIC_DEFAULT mylogger

◆ spa_log_topic_init

#define spa_log_topic_init (   l,
  topic 
)
Value:
do { \
struct spa_log *_l = l; \
if (SPA_LIKELY(_l)) { \
struct spa_interface *_if = &_l->iface; \
spa_interface_call(_if, struct spa_log_methods, \
topic_init, 1, topic); \
} \
} while(0)
#define SPA_LIKELY(x)
Definition: defs.h:241
Definition: x86_64-redhat-linux-gnu/doc/spa/support/log.h:72
Definition: x86_64-redhat-linux-gnu/doc/spa/support/log.h:106
Definition: hook.h:149
const char * topic
The string identifier for the topic.
Definition: x86_64-redhat-linux-gnu/doc/spa/support/log.h:99

Referenced by _pw_log_topic_new().

◆ spa_log_trace

#define spa_log_trace (   l,
  ... 
)    spa_log_log(l,SPA_LOG_LEVEL_TRACE,__FILE__,__LINE__,__func__,__VA_ARGS__)

◆ spa_log_trace_fp

#define spa_log_trace_fp (   l,
  ... 
)    spa_log_log(l,SPA_LOG_LEVEL_TRACE,__FILE__,__LINE__,__func__,__VA_ARGS__)

◆ spa_log_warn

#define spa_log_warn (   l,
  ... 
)    spa_log_log(l,SPA_LOG_LEVEL_WARN,__FILE__,__LINE__,__func__,__VA_ARGS__)

◆ spa_logt_debug

#define spa_logt_debug (   l,
  t,
  ... 
)    spa_log_logt(l,SPA_LOG_LEVEL_DEBUG,t,__FILE__,__LINE__,__func__,__VA_ARGS__)

◆ spa_logt_error

#define spa_logt_error (   l,
  t,
  ... 
)    spa_log_logt(l,SPA_LOG_LEVEL_ERROR,t,__FILE__,__LINE__,__func__,__VA_ARGS__)

◆ spa_logt_info

#define spa_logt_info (   l,
  t,
  ... 
)    spa_log_logt(l,SPA_LOG_LEVEL_INFO,t,__FILE__,__LINE__,__func__,__VA_ARGS__)

◆ spa_logt_trace

#define spa_logt_trace (   l,
  t,
  ... 
)    spa_log_logt(l,SPA_LOG_LEVEL_TRACE,t,__FILE__,__LINE__,__func__,__VA_ARGS__)

◆ spa_logt_warn

#define spa_logt_warn (   l,
  t,
  ... 
)    spa_log_logt(l,SPA_LOG_LEVEL_WARN,t,__FILE__,__LINE__,__func__,__VA_ARGS__)

◆ SPA_TYPE_INTERFACE_Log

#define SPA_TYPE_INTERFACE_Log   SPA_TYPE_INFO_INTERFACE_BASE "Log"

The Log interface.

Enumeration Type Documentation

◆ spa_log_level

Enumerator
SPA_LOG_LEVEL_NONE 
SPA_LOG_LEVEL_ERROR 
SPA_LOG_LEVEL_WARN 
SPA_LOG_LEVEL_INFO 
SPA_LOG_LEVEL_DEBUG 
SPA_LOG_LEVEL_TRACE 

Function Documentation

◆ spa_log_impl_log()

void spa_log_impl_log ( void *  object,
enum spa_log_level  level,
const char *  file,
int  line,
const char *  func,
const char *  fmt,
  ... 
)
inline

◆ spa_log_impl_logt()

void spa_log_impl_logt ( void *  object,
enum spa_log_level  level,
const struct spa_log_topic topic,
const char *  file,
int  line,
const char *  func,
const char *  fmt,
  ... 
)
inline

◆ spa_log_impl_logtv()

void spa_log_impl_logtv ( void *  object,
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 
)
inline

◆ spa_log_impl_logv()

void spa_log_impl_logv ( void *  object,
enum spa_log_level  level,
const char *  file,
int  line,
const char *  func,
const char *  fmt,
va_list  args 
)
inline

◆ spa_log_impl_topic_init()

void spa_log_impl_topic_init ( void *  object,
struct spa_log_topic topic 
)
inline