PipeWire: spa/debug/log.h Source File

PipeWire 1.0.3

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 {
29 struct spa_debug_context ctx;
30 struct spa_log *log;
31 enum spa_log_level level;
32 const struct spa_log_topic *topic;
33 const char *file;
34 int line;
35 const char *func;
36};
37
38 SPA_PRINTF_FUNC(2,3)
39static inline void spa_debug_log_log(struct spa_debug_context *ctx, const char *fmt, ...)
40{
41 struct spa_debug_log_ctx *c = SPA_CONTAINER_OF(ctx, struct spa_debug_log_ctx, ctx);
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)
57
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 */
dict.h
spa/debug/dict.h
format.h
spa/debug/format.h
pod.h
spa/debug/pod.h
defs.h
spa/utils/defs.h
spa_debug_log_log
static void spa_debug_log_log(struct spa_debug_context *ctx, const char *fmt,...)
Definition log.h:44
spa_log_level
spa_log_level
Definition log.h:45
spa_log_logtv
#define spa_log_logtv(l, lev, topic,...)
Definition log.h:250
SPA_CONTAINER_OF
#define SPA_CONTAINER_OF(p, t, m)
Definition defs.h:212
SPA_PRINTF_FUNC
#define SPA_PRINTF_FUNC(fmt, arg1)
Definition defs.h:277
context.h
spa/debug/context.h
mem.h
spa/debug/mem.h
log.h
spa/support/log.h
spa_debug_context
Definition context.h:33
spa_debug_log_ctx
Definition log.h:33
spa_debug_log_ctx::func
const char * func
Definition log.h:40
spa_debug_log_ctx::line
int line
Definition log.h:39
spa_debug_log_ctx::log
struct spa_log * log
Definition log.h:35
spa_debug_log_ctx::level
enum spa_log_level level
Definition log.h:36
spa_debug_log_ctx::ctx
struct spa_debug_context ctx
Definition log.h:34
spa_debug_log_ctx::file
const char * file
Definition log.h:38
spa_debug_log_ctx::topic
const struct spa_log_topic * topic
Definition log.h:37
spa_log_topic
Identifier for a topic.
Definition log.h:83
spa_log
Definition log.h:61