PipeWire: log.h Source File

PipeWire 0.3.26

log.h
Go to the documentation of this file.
1 /* PipeWire
2 *
3 * Copyright © 2018 Wim Taymans
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24
25 #ifndef PIPEWIRE_LOG_H
26 #define PIPEWIRE_LOG_H
27
28 #include <spa/support/log.h>
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
44 extern enum spa_log_level pw_log_level;
45
49 void pw_log_set(struct spa_log *log);
50
52 struct spa_log *pw_log_get(void);
53
55 void pw_log_set_level(enum spa_log_level level);
56
57
59 void
60 pw_log_log(enum spa_log_level level,
61 const char *file,
62 int line, const char *func,
63 const char *fmt, ...) SPA_PRINTF_FUNC(5, 6);
64
66 void
67 pw_log_logv(enum spa_log_level level,
68 const char *file,
69 int line, const char *func,
70 const char *fmt, va_list args) SPA_PRINTF_FUNC(5, 0);
71
72
74 #define pw_log_level_enabled(lev) (pw_log_level >= (lev))
75
76 #define pw_log(lev,...) \
77 ({ \
78 if (SPA_UNLIKELY(pw_log_level_enabled (lev))) \
79 pw_log_log(lev,__FILE__,__LINE__,__func__,__VA_ARGS__); \
80 })
81
82 #define pw_log_error(...) pw_log(SPA_LOG_LEVEL_ERROR,__VA_ARGS__)
83 #define pw_log_warn(...) pw_log(SPA_LOG_LEVEL_WARN,__VA_ARGS__)
84 #define pw_log_info(...) pw_log(SPA_LOG_LEVEL_INFO,__VA_ARGS__)
85 #define pw_log_debug(...) pw_log(SPA_LOG_LEVEL_DEBUG,__VA_ARGS__)
86 #define pw_log_trace(...) pw_log(SPA_LOG_LEVEL_TRACE,__VA_ARGS__)
87
88 #ifndef FASTPATH
89 #define pw_log_trace_fp(...) pw_log(SPA_LOG_LEVEL_TRACE,__VA_ARGS__)
90 #else
91 #define pw_log_trace_fp(...)
92 #endif
93
94 #ifdef __cplusplus
95 }
96 #endif
97 #endif /* PIPEWIRE_LOG_H */
pw_log::pw_log_log
SPA_EXPORT void pw_log_log(enum spa_log_level level, const char *file, int line, const char *func, const char *fmt,...)
Log a message.
Definition: log.c:93
pw_log::pw_log_set
SPA_EXPORT void pw_log_set(struct spa_log *log)
Set the global log interface.
Definition: log.c:49
pw_log::pw_log_logv
SPA_EXPORT void pw_log_logv(enum spa_log_level level, const char *file, int line, const char *func, const char *fmt, va_list args)
Log a message with va_list.
Definition: log.c:121
pw_log::pw_log_set_level
SPA_EXPORT void pw_log_set_level(enum spa_log_level level)
Set the global log level.
Definition: log.c:75
pw_log::pw_log_get
SPA_EXPORT struct spa_log * pw_log_get(void)
Get the global log interface.
Definition: log.c:65
args
static uint32_t int int const char va_list args
Definition: core.h:327
pw_log_level
enum spa_log_level pw_log_level
The global log level.
Definition: log.c:40