PipeWire 1.1.0
Loading...
Searching...
No Matches
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#include <spa/debug/dict.h>
19#include <spa/debug/format.h>
20#include <spa/debug/mem.h>
21#include <spa/debug/pod.h>
22
28struct spa_debug_log_ctx {
30 struct spa_log *log;
32 const struct spa_log_topic *topic;
33 const char *file;
34 int line;
35 const char *func;
36};
39static inline void spa_debug_log_log(struct spa_debug_context *ctx, const char *fmt, ...)
42 va_list args;
43 va_start(args, fmt);
44 spa_log_logtv(c->log, c->level, c->topic, c->file, c->line, c->func, fmt, args);
45 va_end(args);
46}
47
48#define SPA_LOGF_DEBUG_INIT(_l,_lev,_t,_file,_line,_func) \
49 (struct spa_debug_log_ctx){ { spa_debug_log_log }, _l, _lev, _t, \
50 _file, _line, _func }
51
52#define SPA_LOGT_DEBUG_INIT(_l,_lev,_t) \
53 SPA_LOGF_DEBUG_INIT(_l,_lev,_t,__FILE__,__LINE__,__func__)
54
55#define SPA_LOG_DEBUG_INIT(l,lev) \
56 SPA_LOGT_DEBUG_INIT(l,lev,SPA_LOG_TOPIC_DEFAULT)
58#define spa_debug_log_pod(l,lev,indent,info,pod) \
59({ \
60 struct spa_debug_log_ctx c = SPA_LOG_DEBUG_INIT(l,lev); \
61 if (SPA_UNLIKELY(spa_log_level_topic_enabled(c.log, c.topic, c.level))) \
62 spa_debugc_pod(&c.ctx, indent, info, pod); \
63})
64
65#define spa_debug_log_format(l,lev,indent,info,format) \
66({ \
67 struct spa_debug_log_ctx c = SPA_LOG_DEBUG_INIT(l,lev); \
68 if (SPA_UNLIKELY(spa_log_level_topic_enabled(c.log, c.topic, c.level))) \
69 spa_debugc_format(&c.ctx, indent, info, format); \
70})
71
72#define spa_debug_log_mem(l,lev,indent,data,len) \
73({ \
74 struct spa_debug_log_ctx c = SPA_LOG_DEBUG_INIT(l,lev); \
75 if (SPA_UNLIKELY(spa_log_level_topic_enabled(c.log, c.topic, c.level))) \
76 spa_debugc_mem(&c.ctx, indent, data, len); \
77})
78
79#define spa_debug_log_dict(l,lev,indent,dict) \
80({ \
81 struct spa_debug_log_ctx c = SPA_LOG_DEBUG_INIT(l,lev); \
82 if (SPA_UNLIKELY(spa_log_level_topic_enabled(c.log, c.topic, c.level))) \
83 spa_debugc_dict(&c.ctx, indent, dict); \
84})
85
90#ifdef __cplusplus
91} /* extern "C" */
92#endif
93
94#endif /* SPA_DEBUG_LOG_H */
spa/debug/dict.h
spa/debug/format.h
spa/debug/pod.h
spa/utils/defs.h
static void spa_debug_log_log(struct spa_debug_context *ctx, const char *fmt,...)
Definition log.h:44
spa_log_level
Definition log.h:45
#define spa_log_logtv(l, lev, topic,...)
Definition log.h:270
#define SPA_CONTAINER_OF(p, t, m)
Definition defs.h:225
#define SPA_PRINTF_FUNC(fmt, arg1)
Definition defs.h:285
spa/debug/context.h
spa/debug/mem.h
spa/support/log.h
Definition context.h:33
Definition log.h:33
const char * func
Definition log.h:40
int line
Definition log.h:39
struct spa_log * log
Definition log.h:35
enum spa_log_level level
Definition log.h:36
struct spa_debug_context ctx
Definition log.h:34
const char * file
Definition log.h:38
const struct spa_log_topic * topic
Definition log.h:37
Identifier for a topic.
Definition log.h:83
Definition log.h:61