PipeWire 0.3.79
Loading...
Searching...
No Matches
spa/include/spa/debug/log.h
Go to the documentation of this file.
1/* Simple Plugin API */
2/* SPDX-FileCopyrightText: Copyright © 2022 Wim Taymans */
3/* SPDX-License-Identifier: MIT */
4
5#ifndef SPA_DEBUG_LOG_H
6#define SPA_DEBUG_LOG_H
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12#include <stdio.h>
13#include <stdarg.h>
14
15#include <spa/utils/defs.h>
16#include <spa/support/log.h>
17#include <spa/debug/context.h>
18
24struct spa_debug_log_ctx {
26 struct spa_log *log;
28 const struct spa_log_topic *topic;
29 const char *file;
30 int line;
31 const char *func;
32};
35static inline void spa_debug_log_log(struct spa_debug_context *ctx, const char *fmt, ...)
37 struct spa_debug_log_ctx *c = (struct spa_debug_log_ctx*)ctx;
38 va_list args;
39 va_start(args, fmt);
40 spa_log_logtv(c->log, c->level, c->topic, c->file, c->line, c->func, fmt, args);
41 va_end(args);
42}
43
44#define SPA_LOGF_DEBUG_INIT(_l,_lev,_t,_file,_line,_func) \
45 (struct spa_debug_log_ctx){ { spa_debug_log_log }, _l, _lev, _t, \
46 _file, _line, _func }
47
48#define SPA_LOGT_DEBUG_INIT(_l,_lev,_t) \
49 SPA_LOGF_DEBUG_INIT(_l,_lev,_t,__FILE__,__LINE__,__func__)
50
51#define SPA_LOG_DEBUG_INIT(l,lev) \
52 SPA_LOGT_DEBUG_INIT(l,lev,SPA_LOG_TOPIC_DEFAULT)
54#define spa_debug_log_pod(l,lev,indent,info,pod) \
55({ \
56 struct spa_debug_log_ctx c = SPA_LOG_DEBUG_INIT(l,lev); \
57 if (SPA_UNLIKELY(spa_log_level_topic_enabled(c.log, c.topic, c.level))) \
58 spa_debugc_pod(&c.ctx, indent, info, pod); \
59})
60
61#define spa_debug_log_format(l,lev,indent,info,format) \
62({ \
63 struct spa_debug_log_ctx c = SPA_LOG_DEBUG_INIT(l,lev); \
64 if (SPA_UNLIKELY(spa_log_level_topic_enabled(c.log, c.topic, c.level))) \
65 spa_debugc_format(&c.ctx, indent, info, format); \
66})
67
68#define spa_debug_log_mem(l,lev,indent,data,len) \
69({ \
70 struct spa_debug_log_ctx c = SPA_LOG_DEBUG_INIT(l,lev); \
71 if (SPA_UNLIKELY(spa_log_level_topic_enabled(c.log, c.topic, c.level))) \
72 spa_debugc_mem(&c.ctx, indent, data, len); \
73})
74
75#define spa_debug_log_dict(l,lev,indent,dict) \
76({ \
77 struct spa_debug_log_ctx c = SPA_LOG_DEBUG_INIT(l,lev); \
78 if (SPA_UNLIKELY(spa_log_level_topic_enabled(c.log, c.topic, c.level))) \
79 spa_debugc_dict(&c.ctx, indent, dict); \
80})
81
86#ifdef __cplusplus
87} /* extern "C" */
88#endif
89
90#endif /* SPA_DEBUG_LOG_H */
spa/utils/defs.h
static void spa_debug_log_log(struct spa_debug_context *ctx, const char *fmt,...)
Definition: spa/include/spa/debug/log.h:40
spa_log_level
Definition: spa/include/spa/support/log.h:45
#define spa_log_logtv(l, lev, topic,...)
Definition: spa/include/spa/support/log.h:248
#define SPA_PRINTF_FUNC(fmt, arg1)
Definition: defs.h:273
spa/debug/context.h
spa/support/log.h
Definition: spa/include/spa/debug/context.h:33
Definition: spa/include/spa/debug/log.h:29
const char * func
Definition: spa/include/spa/debug/log.h:36
int line
Definition: spa/include/spa/debug/log.h:35
struct spa_log * log
Definition: spa/include/spa/debug/log.h:31
enum spa_log_level level
Definition: spa/include/spa/debug/log.h:32
struct spa_debug_context ctx
Definition: spa/include/spa/debug/log.h:30
const char * file
Definition: spa/include/spa/debug/log.h:34
const struct spa_log_topic * topic
Definition: spa/include/spa/debug/log.h:33
Identifier for a topic.
Definition: spa/include/spa/support/log.h:83
Definition: spa/include/spa/support/log.h:61