36#define SPA_LOG_TOPIC_DEFAULT NULL
50#define SPA_TYPE_INTERFACE_Log SPA_TYPE_INFO_INTERFACE_BASE "Log"
56#define SPA_VERSION_LOG 0
75#define SPA_VERSION_LOG_TOPIC 0
93#define SPA_VERSION_LOG_TOPIC_ENUM 0
103#define SPA_VERSION_LOG_METHODS 1
120 void (*
log) (
void *object,
142 void (*
logv) (
void *object,
166 void (*
logt) (
void *object,
191 void (*
logtv) (
void *object,
213#define SPA_LOG_TOPIC(v, t) \
214 (struct spa_log_topic){ .version = (v), .topic = (t)}
233 if (topic && topic->has_custom_level)
234 max_level = topic->level;
238 return level <= max_level;
242#define spa_log_logt(l,lev,topic,...) \
244 struct spa_log *_l = l; \
245 if (SPA_UNLIKELY(spa_log_level_topic_enabled(_l, topic, lev))) { \
246 struct spa_interface *_if = &_l->iface; \
247 if (!spa_interface_call(_if, \
248 struct spa_log_methods, logt, 1, \
251 spa_interface_call(_if, \
252 struct spa_log_methods, log, 0, \
258#define spa_log_logtv(l,lev,topic,...) \
260 struct spa_log *_l = l; \
261 if (SPA_UNLIKELY(spa_log_level_topic_enabled(_l, topic, lev))) { \
262 struct spa_interface *_if = &_l->iface; \
263 if (!spa_interface_call(_if, \
264 struct spa_log_methods, logtv, 1, \
267 spa_interface_call(_if, \
268 struct spa_log_methods, logv, 0, \
273#define spa_logt_lev(l,lev,t,...) \
274 spa_log_logt(l,lev,t,__FILE__,__LINE__,__func__,__VA_ARGS__)
276#define spa_log_lev(l,lev,...) \
277 spa_logt_lev(l,lev,SPA_LOG_TOPIC_DEFAULT,__VA_ARGS__)
279#define spa_log_log(l,lev,...) \
280 spa_log_logt(l,lev,SPA_LOG_TOPIC_DEFAULT,__VA_ARGS__)
282#define spa_log_logv(l,lev,...) \
283 spa_log_logtv(l,lev,SPA_LOG_TOPIC_DEFAULT,__VA_ARGS__)
285#define spa_log_error(l,...) spa_log_lev(l,SPA_LOG_LEVEL_ERROR,__VA_ARGS__)
286#define spa_log_warn(l,...) spa_log_lev(l,SPA_LOG_LEVEL_WARN,__VA_ARGS__)
287#define spa_log_info(l,...) spa_log_lev(l,SPA_LOG_LEVEL_INFO,__VA_ARGS__)
288#define spa_log_debug(l,...) spa_log_lev(l,SPA_LOG_LEVEL_DEBUG,__VA_ARGS__)
289#define spa_log_trace(l,...) spa_log_lev(l,SPA_LOG_LEVEL_TRACE,__VA_ARGS__)
291#define spa_logt_error(l,t,...) spa_logt_lev(l,SPA_LOG_LEVEL_ERROR,t,__VA_ARGS__)
292#define spa_logt_warn(l,t,...) spa_logt_lev(l,SPA_LOG_LEVEL_WARN,t,__VA_ARGS__)
293#define spa_logt_info(l,t,...) spa_logt_lev(l,SPA_LOG_LEVEL_INFO,t,__VA_ARGS__)
294#define spa_logt_debug(l,t,...) spa_logt_lev(l,SPA_LOG_LEVEL_DEBUG,t,__VA_ARGS__)
295#define spa_logt_trace(l,t,...) spa_logt_lev(l,SPA_LOG_LEVEL_TRACE,t,__VA_ARGS__)
298#define spa_log_trace_fp(l,...) spa_log_lev(l,SPA_LOG_LEVEL_TRACE,__VA_ARGS__)
300#define spa_log_trace_fp(l,...)
310#define SPA_LOG_TOPIC_ENUM_NAME "spa_log_topic_enum"
317#define SPA_LOG_TOPIC_ENUM_DEFINE(s, e) \
318 SPA_EXPORT struct spa_log_topic_enum spa_log_topic_enum = (struct spa_log_topic_enum) { \
319 .version = SPA_VERSION_LOG_TOPIC_ENUM, \
330#define SPA_LOG_TOPIC_REGISTER(v) \
331 __attribute__((used)) __attribute__((retain)) \
332 __attribute__((section("spa_log_topic"))) __attribute__((aligned(__alignof__(struct spa_log_topic *)))) \
333 static struct spa_log_topic * const spa_log_topic_export_##v = &v
340#define SPA_LOG_TOPIC_DEFINE(var,name) \
341 struct spa_log_topic var = SPA_LOG_TOPIC(SPA_VERSION_LOG_TOPIC, name); \
342 SPA_LOG_TOPIC_REGISTER(var)
349#define SPA_LOG_TOPIC_DEFINE_STATIC(var,name) \
350 static struct spa_log_topic var = SPA_LOG_TOPIC(SPA_VERSION_LOG_TOPIC, name); \
351 SPA_LOG_TOPIC_REGISTER(var)
359#define SPA_LOG_TOPIC_ENUM_DEFINE_REGISTERED \
360 extern struct spa_log_topic * const __start_spa_log_topic[]; \
361 extern struct spa_log_topic * const __stop_spa_log_topic[]; \
362 SPA_LOG_TOPIC_ENUM_DEFINE(__start_spa_log_topic, __stop_spa_log_topic)
367#define SPA_KEY_LOG_LEVEL "log.level"
368#define SPA_KEY_LOG_COLORS "log.colors"
370#define SPA_KEY_LOG_FILE "log.file"
372#define SPA_KEY_LOG_TIMESTAMP "log.timestamp"
373#define SPA_KEY_LOG_LINE "log.line"
374#define SPA_KEY_LOG_PATTERNS "log.patterns"
#define spa_interface_call(iface, method_type, method, vers,...)
Invoke method named method in the callbacks on the given interface object.
Definition hook.h:238
spa_log_level
Definition log.h:45
static void spa_log_topic_init(struct spa_log *log, struct spa_log_topic *topic)
Definition log.h:228
static bool spa_log_level_topic_enabled(const struct spa_log *log, const struct spa_log_topic *topic, enum spa_log_level level)
Definition log.h:236
@ SPA_LOG_LEVEL_INFO
Definition log.h:49
@ SPA_LOG_LEVEL_NONE
Definition log.h:46
@ SPA_LOG_LEVEL_TRACE
Definition log.h:51
@ SPA_LOG_LEVEL_DEBUG
Definition log.h:50
@ SPA_LOG_LEVEL_ERROR
Definition log.h:47
@ SPA_LOG_LEVEL_WARN
Definition log.h:48
#define SPA_PRINTF_FUNC(fmt, arg1)
Definition defs.h:295
#define SPA_UNLIKELY(x)
Definition defs.h:369
void(* logv)(void *object, enum spa_log_level level, const char *file, int line, const char *func, const char *fmt, va_list args)
Log a message with the given log level.
Definition log.h:154
uint32_t version
Definition log.h:116
void(* 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)
Log a message with the given log level for the given topic.
Definition log.h:203
void(* 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,...)
Log a message with the given log level for the given topic.
Definition log.h:178
void(* topic_init)(void *object, struct spa_log_topic *topic)
Initializes a spa_log_topic to the correct logging level.
Definition log.h:221
void(* log)(void *object, enum spa_log_level level, const char *file, int line, const char *func, const char *fmt,...)
Log a message with the given log level.
Definition log.h:132
Enumeration of log topics in a plugin.
Definition log.h:102
struct spa_log_topic *const *const topics_end
End of topics array.
Definition log.h:109
struct spa_log_topic *const *const topics
Array of pointers to log topics.
Definition log.h:107
uint32_t version
Definition log.h:105
Identifier for a topic.
Definition log.h:83
uint32_t version
the version of this topic.
Definition log.h:88
bool has_custom_level
False if this topic follows the Log level.
Definition log.h:94
enum spa_log_level level
Logging level set for this topic.
Definition log.h:92
const char * topic
The string identifier for the topic.
Definition log.h:90
struct spa_interface iface
Definition log.h:66
enum spa_log_level level
Logging level, everything above this level is not logged.
Definition log.h:70