PipeWire  1.4.1
file.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_FILE_H
6 #define SPA_DEBUG_FILE_H
7 
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 
12 #include <stdio.h>
13 #include <stdarg.h>
14 #include <ctype.h>
15 
16 #include <spa/utils/defs.h>
17 #include <spa/support/log.h>
18 #include <spa/debug/context.h>
19 #include <spa/debug/dict.h>
20 #include <spa/debug/format.h>
21 #include <spa/debug/mem.h>
22 #include <spa/debug/pod.h>
23 
29 #ifndef SPA_API_DEBUG_FILE
30  #ifdef SPA_API_IMPL
31  #define SPA_API_DEBUG_FILE SPA_API_IMPL
32  #else
33  #define SPA_API_DEBUG_FILE static inline
34  #endif
35 #endif
36 
37 struct spa_debug_file_ctx {
38  struct spa_debug_context ctx;
39  FILE *f;
40 };
41 
42 SPA_PRINTF_FUNC(2,3)
43 SPA_API_DEBUG_FILE void spa_debug_file_log(struct spa_debug_context *ctx, const char *fmt, ...)
44 {
46  va_list args;
47  va_start(args, fmt);
48  vfprintf(c->f, fmt, args); fputc('\n', c->f);
49  va_end(args);
50 }
51 
52 #define SPA_DEBUG_FILE_INIT(_f) \
53  (struct spa_debug_file_ctx){ { spa_debug_file_log }, _f, }
54 
55 #define spa_debug_file_error_location(f,loc,fmt,...) \
56 ({ \
57  struct spa_debug_file_ctx c = SPA_DEBUG_FILE_INIT(f); \
58  if (fmt) spa_debugc(&c.ctx, fmt, __VA_ARGS__); \
59  spa_debugc_error_location(&c.ctx, loc); \
60 })
61 
66 #ifdef __cplusplus
67 } /* extern "C" */
68 #endif
69 
70 #endif /* SPA_DEBUG_FILE_H */
spa/debug/dict.h
spa/debug/format.h
spa/debug/pod.h
spa/utils/defs.h
uint32_t int int const char va_list args
Definition: core.h:434
va_end(args)
va_start(args, message)
SPA_API_DEBUG_FILE void spa_debug_file_log(struct spa_debug_context *ctx, const char *fmt,...)
Definition: file.h:50
#define SPA_API_DEBUG_FILE
Definition: file.h:40
#define SPA_CONTAINER_OF(p, t, m)
Definition: defs.h:235
#define SPA_PRINTF_FUNC(fmt, arg1)
Definition: defs.h:295
spa/debug/context.h
spa/debug/mem.h
spa/support/log.h
Definition: context.h:45
Definition: file.h:44
FILE * f
Definition: file.h:46
struct spa_debug_context ctx
Definition: file.h:45