PipeWire  0.3.29
src/pipewire/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 
48 extern enum spa_log_level pw_log_level;
49 
53 void pw_log_set(struct spa_log *log);
54 
56 struct spa_log *pw_log_get(void);
57 
60 
61 
63 void
65  const char *file,
66  int line, const char *func,
67  const char *fmt, ...) SPA_PRINTF_FUNC(5, 6);
68 
70 void
72  const char *file,
73  int line, const char *func,
74  const char *fmt, va_list args) SPA_PRINTF_FUNC(5, 0);
75 
76 
78 #define pw_log_level_enabled(lev) (pw_log_level >= (lev))
79 
80 #define pw_log(lev,...) \
81 ({ \
82  if (SPA_UNLIKELY(pw_log_level_enabled (lev))) \
83  pw_log_log(lev,__FILE__,__LINE__,__func__,__VA_ARGS__); \
84 })
85 
86 #define pw_log_error(...) pw_log(SPA_LOG_LEVEL_ERROR,__VA_ARGS__)
87 #define pw_log_warn(...) pw_log(SPA_LOG_LEVEL_WARN,__VA_ARGS__)
88 #define pw_log_info(...) pw_log(SPA_LOG_LEVEL_INFO,__VA_ARGS__)
89 #define pw_log_debug(...) pw_log(SPA_LOG_LEVEL_DEBUG,__VA_ARGS__)
90 #define pw_log_trace(...) pw_log(SPA_LOG_LEVEL_TRACE,__VA_ARGS__)
91 
92 #ifndef FASTPATH
93 #define pw_log_trace_fp(...) pw_log(SPA_LOG_LEVEL_TRACE,__VA_ARGS__)
94 #else
95 #define pw_log_trace_fp(...)
96 #endif
97 
102 #ifdef __cplusplus
103 }
104 #endif
105 #endif /* PIPEWIRE_LOG_H */
void void pw_log_logv(enum spa_log_level level, const char *file, int line, const char *func, const char *fmt, va_list args) SPA_PRINTF_FUNC(5
Log a message.
void pw_log_set(struct spa_log *log)
Configure a logging module.
Definition: log.c:47
void pw_log_log(enum spa_log_level level, const char *file, int line, const char *func, const char *fmt,...) SPA_PRINTF_FUNC(5
Log a message.
struct spa_log * pw_log_get(void)
Get the log interface.
Definition: log.c:62
void pw_log_set_level(enum spa_log_level level)
Configure the logging level.
Definition: log.c:71
enum spa_log_level pw_log_level
The global log level.
Definition: log.c:39
static uint32_t int int const char va_list args
Definition: core.h:330
spa_log_level
Definition: output/doc/spa/support/log.h:45
enum spa_log_level level const char int const char * func
Definition: log-impl.h:46
enum spa_log_level level const char * file
Definition: log-impl.h:43
enum spa_log_level level const char int const char const char * fmt
Definition: log-impl.h:47
enum spa_log_level level const char int line
Definition: log-impl.h:45
#define SPA_PRINTF_FUNC(fmt, arg1)
Definition: defs.h:203
Definition: output/doc/spa/support/log.h:61
enum spa_log_level level
Logging level, everything above this level is not logged.
Definition: output/doc/spa/support/log.h:68