PipeWire: pipewire/log.h Source File

PipeWire 1.0.3

Loading...
Searching...
No Matches
log.h
Go to the documentation of this file.
1/* PipeWire */
2/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
3/* SPDX-License-Identifier: MIT */
4
5#ifndef PIPEWIRE_LOG_H
6#define PIPEWIRE_LOG_H
7
8#include <spa/support/log.h>
9
10#ifdef __cplusplus
11extern "C" {
12#endif
13
28extern enum spa_log_level pw_log_level;
29
30extern struct spa_log_topic *PW_LOG_TOPIC_DEFAULT;
31
35void pw_log_set(struct spa_log *log);
36
38struct spa_log *pw_log_get(void);
39
41void pw_log_set_level(enum spa_log_level level);
42
44void
45 pw_log_logt(enum spa_log_level level,
46 const struct spa_log_topic *topic,
47 const char *file,
48 int line, const char *func,
49 const char *fmt, ...) SPA_PRINTF_FUNC(6, 7);
50
52void
53 pw_log_logtv(enum spa_log_level level,
54 const struct spa_log_topic *topic,
55 const char *file,
56 int line, const char *func,
57 const char *fmt, va_list args) SPA_PRINTF_FUNC(6, 0);
58
59
60
62void
63 pw_log_log(enum spa_log_level level,
64 const char *file,
65 int line, const char *func,
66 const char *fmt, ...) SPA_PRINTF_FUNC(5, 6);
67
69void
70 pw_log_logv(enum spa_log_level level,
71 const char *file,
72 int line, const char *func,
73 const char *fmt, va_list args) SPA_PRINTF_FUNC(5, 0);
74
86#define PW_LOG_TOPIC_STATIC(var, topic) \
87 static struct spa_log_topic var##__LINE__ = SPA_LOG_TOPIC(0, topic); \
88 static struct spa_log_topic *var = &(var##__LINE__)
89
94#define PW_LOG_TOPIC_EXTERN(var) \
95 extern struct spa_log_topic *var
96
101#define PW_LOG_TOPIC(var, topic) \
102 struct spa_log_topic var##__LINE__ = SPA_LOG_TOPIC(0, topic); \
103 struct spa_log_topic *var = &(var##__LINE__)
104
105#define PW_LOG_TOPIC_INIT(var) \
106 spa_log_topic_init(pw_log_get(), var);
107
109#define pw_log_level_enabled(lev) (pw_log_level >= (lev))
110#define pw_log_topic_enabled(lev,t) ((t) && (t)->has_custom_level ? (t)->level >= (lev) : pw_log_level_enabled((lev)))
111
112#define pw_logtv(lev,topic,fmt,ap) \
113({ \
114 if (SPA_UNLIKELY(pw_log_topic_enabled(lev,topic))) \
115 pw_log_logtv(lev,topic,__FILE__,__LINE__,__func__,fmt,ap); \
116})
117
118#define pw_logt(lev,topic,...) \
119({ \
120 if (SPA_UNLIKELY(pw_log_topic_enabled(lev,topic))) \
121 pw_log_logt(lev,topic,__FILE__,__LINE__,__func__,__VA_ARGS__); \
122})
123
124#define pw_log(lev,...) pw_logt(lev,PW_LOG_TOPIC_DEFAULT,__VA_ARGS__)
125
126#define pw_log_error(...) pw_log(SPA_LOG_LEVEL_ERROR,__VA_ARGS__)
127#define pw_log_warn(...) pw_log(SPA_LOG_LEVEL_WARN,__VA_ARGS__)
128#define pw_log_info(...) pw_log(SPA_LOG_LEVEL_INFO,__VA_ARGS__)
129#define pw_log_debug(...) pw_log(SPA_LOG_LEVEL_DEBUG,__VA_ARGS__)
130#define pw_log_trace(...) pw_log(SPA_LOG_LEVEL_TRACE,__VA_ARGS__)
131
132#define pw_logt_error(t,...) pw_logt(SPA_LOG_LEVEL_ERROR,t,__VA_ARGS__)
133#define pw_logt_warn(t,...) pw_logt(SPA_LOG_LEVEL_WARN,t,__VA_ARGS__)
134#define pw_logt_info(t,...) pw_logt(SPA_LOG_LEVEL_INFO,t,__VA_ARGS__)
135#define pw_logt_debug(t,...) pw_logt(SPA_LOG_LEVEL_DEBUG,t,__VA_ARGS__)
136#define pw_logt_trace(t,...) pw_logt(SPA_LOG_LEVEL_TRACE,t,__VA_ARGS__)
137
138#ifndef FASTPATH
139#define pw_log_trace_fp(...) pw_log(SPA_LOG_LEVEL_TRACE,__VA_ARGS__)
140#else
141#define pw_log_trace_fp(...)
142#endif
143
148#ifdef __cplusplus
149}
150#endif
151#endif /* PIPEWIRE_LOG_H */
pw_log_get
struct spa_log * pw_log_get(void)
Get the log interface.
Definition log.c:80
pw_log_logtv
void void pw_log_logtv(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) 1(6
Log a message for a topic.
pw_log_set
void pw_log_set(struct spa_log *log)
Configure a logging module.
Definition log.c:65
pw_log_logv
void void void void pw_log_logv(enum spa_log_level level, const char *file, int line, const char *func, const char *fmt, va_list args) 1(5
Log a message for the default topic.
pw_log_set_level
void pw_log_set_level(enum spa_log_level level)
Configure the logging level.
Definition log.c:89
PW_LOG_TOPIC_DEFAULT
struct spa_log_topic * PW_LOG_TOPIC_DEFAULT
Definition log.c:30
pw_log_level
enum spa_log_level pw_log_level
The global log level.
Definition log.c:25
pw_log_logt
void pw_log_logt(enum spa_log_level level, const struct spa_log_topic *topic, const char *file, int line, const char *func, const char *fmt,...) 1(6
Log a message for a topic.
pw_log_log
void void void pw_log_log(enum spa_log_level level, const char *file, int line, const char *func, const char *fmt,...) 1(5
Log a message for the default topic.
spa_log_level
spa_log_level
Definition log.h:45
SPA_PRINTF_FUNC
#define SPA_PRINTF_FUNC(fmt, arg1)
Definition defs.h:277
log.h
spa/support/log.h
spa_log_topic
Identifier for a topic.
Definition log.h:83
spa_log
Definition log.h:61
spa_log::level
enum spa_log_level level
Logging level, everything above this level is not logged.
Definition log.h:70