PipeWire  0.3.33
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 */
pw_log_level
enum spa_log_level pw_log_level
The global log level.
Definition: log.c:39
SPA_TYPE_None
@ SPA_TYPE_None
Definition: build-12683127/doc/spa/utils/type.h:45
spa_rectangle::width
uint32_t width
Definition: defs.h:87
SPA_TYPE_Float
@ SPA_TYPE_Float
Definition: build-12683127/doc/spa/utils/type.h:50
SPA_POD_CHOICE_BODY_FOREACH
#define SPA_POD_CHOICE_BODY_FOREACH(body, _size, iter)
Definition: iter.h:102
SPA_TYPE_Long
@ SPA_TYPE_Long
Definition: build-12683127/doc/spa/utils/type.h:49
pw_log_log
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.
spa_pod_object_body::type
uint32_t type
one of enum spa_type
Definition: pod/pod.h:170
spa_type_control
const struct spa_type_info spa_type_control[]
Definition: control/type-info.h:45
spa_type_choice
const struct spa_type_info spa_type_choice[]
Definition: utils/type-info.h:69
types.h
spa_log_level
spa_log_level
Definition: build-12683127/doc/spa/support/log.h:46
SPA_TYPE_Id
@ SPA_TYPE_Id
Definition: build-12683127/doc/spa/utils/type.h:47
spa_type_info::type
uint32_t type
Definition: build-12683127/doc/spa/utils/type.h:138
spa_pod_sequence_body::unit
uint32_t unit
Definition: pod/pod.h:227
SPA_TYPE_Int
@ SPA_TYPE_Int
Definition: build-12683127/doc/spa/utils/type.h:48
spa_pod_pointer_body
Definition: pod/pod.h:180
spa_type_info
Definition: build-12683127/doc/spa/utils/type.h:137
spa_pod_object_body
Definition: pod/pod.h:169
spa_pod_prop
Definition: pod/pod.h:199
spa_pod_object_body::id
uint32_t id
id of the object, depends on the object type
Definition: pod/pod.h:171
SPA_EXPORT
#define SPA_EXPORT
Definition: defs.h:208
spa_pod_control
Definition: pod/pod.h:219
spa_rectangle::height
uint32_t height
Definition: defs.h:88
spa_pod_choice_body::child
struct spa_pod child
Definition: pod/pod.h:151
spa_fraction
Definition: defs.h:104
SPA_TYPE_Array
@ SPA_TYPE_Array
Definition: build-12683127/doc/spa/utils/type.h:57
SPA_POD_OBJECT_BODY_FOREACH
#define SPA_POD_OBJECT_BODY_FOREACH(body, size, iter)
Definition: iter.h:118
SPA_POD_TYPE
#define SPA_POD_TYPE(pod)
Definition: pod/pod.h:41
SPA_TYPE_Rectangle
@ SPA_TYPE_Rectangle
Definition: build-12683127/doc/spa/utils/type.h:54
spa_pod_pointer_body::value
const void * value
Definition: pod/pod.h:183
spa_pod_choice_body
Definition: pod/pod.h:148
spa_log::iface
struct spa_interface iface
Definition: build-12683127/doc/spa/support/log.h:65
SPA_LOG_IMPL
SPA_LOG_IMPL(default_log)
DEFAULT_LOG_LEVEL
#define DEFAULT_LOG_LEVEL
Definition: log.c:36
log_ctx::level
enum spa_log_level level
Definition: log.c:157
SPA_PRINTF_FUNC
#define SPA_PRINTF_FUNC(fmt, arg1)
Definition: defs.h:205
SPA_POD_ARRAY_BODY_FOREACH
#define SPA_POD_ARRAY_BODY_FOREACH(body, _size, iter)
Definition: iter.h:94
_log
#define _log(_c, fmt,...)
Definition: log.c:163
SPA_TYPE_Pointer
@ SPA_TYPE_Pointer
Definition: build-12683127/doc/spa/utils/type.h:61
spa_pod_sequence_body
Definition: pod/pod.h:226
spa_rectangle
Definition: defs.h:86
spa_type_info::name
const char * name
Definition: build-12683127/doc/spa/utils/type.h:140
pw_log_log_object
void pw_log_log_object(enum spa_log_level level, const char *file, int line, const char *func, uint32_t flags, const void *object)
Definition: log.c:321
spa_pod
Definition: pod/pod.h:50
SPA_TYPE_Fd
@ SPA_TYPE_Fd
Definition: build-12683127/doc/spa/utils/type.h:62
log_ctx::func
const char * func
Definition: log.c:160
SPA_TYPE_String
@ SPA_TYPE_String
Definition: build-12683127/doc/spa/utils/type.h:52
SPA_TYPE_Bitmap
@ SPA_TYPE_Bitmap
Definition: build-12683127/doc/spa/utils/type.h:56
spa_pod_control::type
uint32_t type
type of control, enum spa_control_type
Definition: pod/pod.h:221
log-impl.h
spa_log
Definition: build-12683127/doc/spa/support/log.h:61
pw_log_logv
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:115
SPA_TYPE_Bool
@ SPA_TYPE_Bool
Definition: build-12683127/doc/spa/utils/type.h:46
spa_pod_array_body
Definition: pod/pod.h:122
spa_pod_pointer_body::type
uint32_t type
pointer id, one of enum spa_type
Definition: pod/pod.h:181
SPA_POD_SEQUENCE_BODY_FOREACH
#define SPA_POD_SEQUENCE_BODY_FOREACH(body, size, iter)
Definition: iter.h:126
spa_log::level
enum spa_log_level level
Logging level, everything above this level is not logged.
Definition: build-12683127/doc/spa/support/log.h:69
SPA_POD_BODY
#define SPA_POD_BODY(pod)
Definition: pod/pod.h:47
spa_pod_prop::key
uint32_t key
key of property, list of valid keys depends on the object type
Definition: pod/pod.h:200
spa_interface_call
#define spa_interface_call(iface, method_type, method, vers,...)
Invoke method named method in the callbacks on the given interface object.
Definition: hook.h:198
spa_pod::size
uint32_t size
Definition: pod/pod.h:51
pw_log_level_enabled
#define pw_log_level_enabled(lev)
Check if a loglevel is enabled.
Definition: src/pipewire/log.h:78
SPA_TYPE_ROOT
#define SPA_TYPE_ROOT
Definition: utils/type-info.h:40
SPA_TYPE_Bytes
@ SPA_TYPE_Bytes
Definition: build-12683127/doc/spa/utils/type.h:53
log_ctx
Definition: log.c:156
SPA_TYPE_Double
@ SPA_TYPE_Double
Definition: build-12683127/doc/spa/utils/type.h:51
SPA_POD_BODY_SIZE
#define SPA_POD_BODY_SIZE(pod)
Definition: pod/pod.h:40
SPA_TYPE_Object
@ SPA_TYPE_Object
Definition: build-12683127/doc/spa/utils/type.h:59
SPA_TYPE_Sequence
@ SPA_TYPE_Sequence
Definition: build-12683127/doc/spa/utils/type.h:60
spa_type_info::values
const struct spa_type_info * values
Definition: build-12683127/doc/spa/utils/type.h:141
spa_pod_control::value
struct spa_pod value
control value, depends on type
Definition: pod/pod.h:222
spa_fraction::denom
uint32_t denom
Definition: defs.h:106
log.h
spa_pod_choice_body::type
uint32_t type
type of choice, one of enum spa_choice_type
Definition: pod/pod.h:149
log_ctx::file
const char * file
Definition: log.c:158
SPA_TYPE_Fraction
@ SPA_TYPE_Fraction
Definition: build-12683127/doc/spa/utils/type.h:55
pw_log_set_level
void pw_log_set_level(enum spa_log_level level)
Set the global log level.
Definition: log.c:71
spa_pod::type
uint32_t type
Definition: pod/pod.h:52
pw_log_get
struct spa_log * pw_log_get(void)
Get the global log interface.
Definition: log.c:62
pw_log_logv
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.
pw_log_is_default
bool pw_log_is_default(void)
Definition: log.c:53
pw_log_log
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:88
spa_debug_type_find
const struct spa_type_info * spa_debug_type_find(const struct spa_type_info *info, uint32_t type)
Definition: types.h:41
spa_pod_prop::flags
uint32_t flags
flags for property
Definition: pod/pod.h:211
iter.h
SPA_TYPE_Choice
@ SPA_TYPE_Choice
Definition: build-12683127/doc/spa/utils/type.h:63
spa_log_methods
Definition: build-12683127/doc/spa/support/log.h:72
SPA_POD_CONTENTS
#define SPA_POD_CONTENTS(type, pod)
Definition: pod/pod.h:45
spa_pod_prop::value
struct spa_pod value
Definition: pod/pod.h:212
spa_fraction::num
uint32_t num
Definition: defs.h:105
spa_pod_choice_body::flags
uint32_t flags
extra flags
Definition: pod/pod.h:150
pw_log_set
void pw_log_set(struct spa_log *log)
Set the global log interface.
Definition: log.c:47
SPA_POD_FOREACH
#define SPA_POD_FOREACH(pod, size, iter)
Definition: iter.h:110
SPA_UNLIKELY
#define SPA_UNLIKELY(x)
Definition: defs.h:235
spa_pod_control::offset
uint32_t offset
media offset
Definition: pod/pod.h:220
log_ctx::line
int line
Definition: log.c:159
pod.h
spa_pod_array_body::child
struct spa_pod child
Definition: pod/pod.h:123
log.h
SPA_TYPE_Struct
@ SPA_TYPE_Struct
Definition: build-12683127/doc/spa/utils/type.h:58
spa_debug_type_find_name
const char * spa_debug_type_find_name(const struct spa_type_info *info, uint32_t type)
Definition: types.h:68