PipeWire
1.7.0
Toggle main menu visibility
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
#include <stdio.h>
9
#include <stdarg.h>
10
11
#include <
spa/utils/defs.h
>
12
#include <
spa/support/log.h
>
13
#include <
spa/debug/context.h
>
14
#include <
spa/debug/buffer.h
>
15
#include <
spa/debug/dict.h
>
16
#include <
spa/debug/format.h
>
17
#include <
spa/debug/mem.h
>
18
#include <
spa/debug/pod.h
>
19
20
#ifdef __cplusplus
21
extern
"C"
{
22
#endif
23
24
#ifndef SPA_API_DEBUG_LOG
25
#ifdef SPA_API_IMPL
26
#define SPA_API_DEBUG_LOG SPA_API_IMPL
27
#else
28
#define SPA_API_DEBUG_LOG static inline
29
#endif
30
#endif
31
36
37
struct
spa_debug_log_ctx
{
38
struct
spa_debug_context
ctx
;
39
struct
spa_log
*
log
;
40
enum
spa_log_level
level
;
41
const
struct
spa_log_topic
*topic;
42
const
char
*
file
;
43
int
line
;
44
const
char
*
func
;
45
};
46
47
SPA_PRINTF_FUNC
(2,3)
48
SPA_API_DEBUG_LOG
void
spa_debug_log_log
(struct
spa_debug_context
*
ctx
, const
char
*
fmt
, ...)
49
{
50
struct
spa_debug_log_ctx
*c =
SPA_CONTAINER_OF
(
ctx
,
struct
spa_debug_log_ctx
,
ctx
);
51
va_list
args
;
52
va_start
(
args
,
fmt
);
53
spa_log_logtv
(c->
log
, c->
level
, c->
topic
, c->
file
, c->
line
, c->
func
,
fmt
,
args
);
54
va_end
(
args
);
55
}
56
57
#define SPA_LOGF_DEBUG_INIT(_l,_lev,_t,_file,_line,_func) \
58
(struct spa_debug_log_ctx){ { spa_debug_log_log }, _l, _lev, _t, \
59
_file, _line, _func }
60
61
#define SPA_LOGT_DEBUG_INIT(_l,_lev,_t) \
62
SPA_LOGF_DEBUG_INIT(_l,_lev,_t,__FILE__,__LINE__,__func__)
63
64
#define SPA_LOG_DEBUG_INIT(l,lev) \
65
SPA_LOGT_DEBUG_INIT(l,lev,SPA_LOG_TOPIC_DEFAULT)
66
67
#define spa_debug_log_pod(l,lev,indent,info,pod) \
68
({ \
69
struct spa_debug_log_ctx c = SPA_LOG_DEBUG_INIT(l,lev); \
70
if (SPA_UNLIKELY(spa_log_level_topic_enabled(c.log, c.topic, c.level))) \
71
spa_debugc_pod(&c.ctx, indent, info, pod); \
72
})
73
74
#define spa_debug_log_format(l,lev,indent,info,format) \
75
({ \
76
struct spa_debug_log_ctx c = SPA_LOG_DEBUG_INIT(l,lev); \
77
if (SPA_UNLIKELY(spa_log_level_topic_enabled(c.log, c.topic, c.level))) \
78
spa_debugc_format(&c.ctx, indent, info, format); \
79
})
80
81
#define spa_debug_log_mem(l,lev,indent,data,len) \
82
({ \
83
struct spa_debug_log_ctx c = SPA_LOG_DEBUG_INIT(l,lev); \
84
if (SPA_UNLIKELY(spa_log_level_topic_enabled(c.log, c.topic, c.level))) \
85
spa_debugc_mem(&c.ctx, indent, data, len); \
86
})
87
88
#define spa_debug_log_dict(l,lev,indent,dict) \
89
({ \
90
struct spa_debug_log_ctx c = SPA_LOG_DEBUG_INIT(l,lev); \
91
if (SPA_UNLIKELY(spa_log_level_topic_enabled(c.log, c.topic, c.level))) \
92
spa_debugc_dict(&c.ctx, indent, dict); \
93
})
94
95
#define spa_debug_log_error_location(l,lev,loc,fmt,...) \
96
({ \
97
struct spa_debug_log_ctx c = SPA_LOG_DEBUG_INIT(l,lev); \
98
if (SPA_UNLIKELY(spa_log_level_topic_enabled(c.log, c.topic, c.level))) { \
99
if (fmt) spa_debugc(&c.ctx, fmt, __VA_ARGS__); \
100
spa_debugc_error_location(&c.ctx, loc); \
101
} \
102
})
103
104
#define spa_debug_log_buffer(l,lev,indent,buffer) \
105
({ \
106
struct spa_debug_log_ctx c = SPA_LOG_DEBUG_INIT(l,lev); \
107
if (SPA_UNLIKELY(spa_log_level_topic_enabled(c.log, c.topic, c.level))) \
108
spa_debugc_buffer(&c.ctx, indent, buffer); \
109
})
110
111
/**
112
* \}
113
*/
114
115
#ifdef __cplusplus
116
}
/* extern "C" */
117
#endif
118
119
#endif
/* SPA_DEBUG_LOG_H */
buffer.h
spa/debug/buffer.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
args
uint32_t int int const char va_list args
Definition
core.h:434
va_end
va_end(args)
va_start
va_start(args, message)
spa_debug_log_log
SPA_API_DEBUG_LOG void spa_debug_log_log(struct spa_debug_context *ctx, const char *fmt,...)
Definition
log.h:55
fmt
const char const char * fmt
Definition
json-builder.h:308
spa_log_level
spa_log_level
Definition
log.h:55
spa_log_logtv
SPA_API_LOG void spa_log_logtv(struct spa_log *l, 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)
Definition
log.h:281
SPA_CONTAINER_OF
#define SPA_CONTAINER_OF(p, t, m)
Definition
defs.h:236
SPA_PRINTF_FUNC
#define SPA_PRINTF_FUNC(fmt, arg1)
Definition
defs.h:298
context.h
spa/debug/context.h
SPA_API_DEBUG_LOG
#define SPA_API_DEBUG_LOG
Definition
log.h:35
mem.h
spa/debug/mem.h
log.h
spa/support/log.h
spa_debug_context
Definition
context.h:46
spa_debug_log_ctx
Definition
log.h:44
spa_debug_log_ctx::func
const char * func
Definition
log.h:51
spa_debug_log_ctx::line
int line
Definition
log.h:50
spa_debug_log_ctx::log
struct spa_log * log
Definition
log.h:46
spa_debug_log_ctx::level
enum spa_log_level level
Definition
log.h:47
spa_debug_log_ctx::ctx
struct spa_debug_context ctx
Definition
log.h:45
spa_debug_log_ctx::file
const char * file
Definition
log.h:49
spa_debug_log_ctx::topic
const struct spa_log_topic * topic
Definition
log.h:48
spa_log_topic
Identifier for a topic.
Definition
log.h:93
spa_log
Definition
log.h:71
spa
debug
log.h
Generated by
1.18.0