PipeWire: spa/debug/file.h Source File

PipeWire 1.6.8

Loading...
Searching...
No Matches
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#include <stdio.h>
9#include <stdarg.h>
10#include <ctype.h>
11
12#include <spa/utils/defs.h>
13#include <spa/support/log.h>
14#include <spa/debug/context.h>
15#include <spa/debug/dict.h>
16#include <spa/debug/format.h>
17#include <spa/debug/mem.h>
18#include <spa/debug/pod.h>
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
28
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
37struct 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{
45 struct spa_debug_file_ctx *c = SPA_CONTAINER_OF(ctx, struct spa_debug_file_ctx, ctx);
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
62/**
63 * \}
64 */
65
66#ifdef __cplusplus
67} /* extern "C" */
68#endif
69
70#endif /* SPA_DEBUG_FILE_H */
dict.h
spa/debug/dict.h
format.h
spa/debug/format.h
pod.h
spa/debug/pod.h
defs.h
spa/utils/defs.h
args
uint32_t int int const char va_list args
Definition core.h:434
va_end
va_end(args)
va_start
va_start(args, message)
spa_debug_file_log
SPA_API_DEBUG_FILE void spa_debug_file_log(struct spa_debug_context *ctx, const char *fmt,...)
Definition file.h:50
SPA_API_DEBUG_FILE
#define SPA_API_DEBUG_FILE
Definition file.h:40
SPA_CONTAINER_OF
#define SPA_CONTAINER_OF(p, t, m)
Definition defs.h:235
SPA_PRINTF_FUNC
#define SPA_PRINTF_FUNC(fmt, arg1)
Definition defs.h:297
context.h
spa/debug/context.h
mem.h
spa/debug/mem.h
log.h
spa/support/log.h
spa_debug_context
Definition context.h:46
spa_debug_file_ctx
Definition file.h:44
spa_debug_file_ctx::f
FILE * f
Definition file.h:46
spa_debug_file_ctx::ctx
struct spa_debug_context ctx
Definition file.h:45