Fix: pass private data to context callbacks
[lttng-ust.git] / liblttng-ust / tracelog.c
CommitLineData
0cb03c85 1/*
c0c0989a 2 * SPDX-License-Identifier: MIT
0cb03c85 3 *
c0c0989a 4 * Copyright (C) 2013-2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
0cb03c85
MD
5 */
6
0cb03c85
MD
7#define _LGPL_SOURCE
8#include <stdio.h>
864a1eda 9#include <ust-helper.h>
0cb03c85
MD
10
11#define TRACEPOINT_CREATE_PROBES
12#define TRACEPOINT_DEFINE
13#include "lttng-ust-tracelog-provider.h"
14
15#define TRACELOG_CB(level) \
4199ddc7
MJ
16 static inline \
17 void __lttng_ust_vtracelog_##level(const char *file, \
18 int line, const char *func, \
19 const char *fmt, va_list ap) \
20 __attribute__((always_inline, format(printf, 4, 0))); \
21 \
22 static inline \
bd9bb3c7 23 void __lttng_ust_vtracelog_##level(const char *file, \
0cb03c85 24 int line, const char *func, \
bd9bb3c7 25 const char *fmt, va_list ap) \
0cb03c85 26 { \
0cb03c85 27 char *msg; \
bd9bb3c7 28 const int len = vasprintf(&msg, fmt, ap); \
0cb03c85 29 \
0cb03c85
MD
30 /* len does not include the final \0 */ \
31 if (len < 0) \
32 goto end; \
33 __tracepoint_cb_lttng_ust_tracelog___##level(file, \
34 line, func, msg, len, \
171fcc6f 35 LTTNG_UST_CALLER_IP()); \
0cb03c85
MD
36 free(msg); \
37 end: \
bd9bb3c7
MRB
38 return; \
39 } \
40 \
4199ddc7
MJ
41 void _lttng_ust_vtracelog_##level(const char *file, \
42 int line, const char *func, \
43 const char *fmt, va_list ap) \
44 __attribute__ ((format(printf, 4, 0))); \
45 \
4b4a1337
MJ
46 void _lttng_ust_vtracelog_##level(const char *file, \
47 int line, const char *func, \
48 const char *fmt, va_list ap); \
bd9bb3c7
MRB
49 void _lttng_ust_vtracelog_##level(const char *file, \
50 int line, const char *func, \
51 const char *fmt, va_list ap) \
52 { \
53 __lttng_ust_vtracelog_##level(file, line, func, fmt, ap); \
54 } \
55 \
4199ddc7
MJ
56 void _lttng_ust_tracelog_##level(const char *file, \
57 int line, const char *func, \
58 const char *fmt, ...) \
59 __attribute__ ((format(printf, 4, 5))); \
60 \
4b4a1337
MJ
61 void _lttng_ust_tracelog_##level(const char *file, \
62 int line, const char *func, \
63 const char *fmt, ...); \
bd9bb3c7
MRB
64 void _lttng_ust_tracelog_##level(const char *file, \
65 int line, const char *func, \
66 const char *fmt, ...) \
67 { \
68 va_list ap; \
69 \
70 va_start(ap, fmt); \
71 __lttng_ust_vtracelog_##level(file, line, func, fmt, ap); \
0cb03c85
MD
72 va_end(ap); \
73 }
74
c4d667ed
MD
75TRACELOG_CB(TRACE_EMERG)
76TRACELOG_CB(TRACE_ALERT)
77TRACELOG_CB(TRACE_CRIT)
78TRACELOG_CB(TRACE_ERR)
79TRACELOG_CB(TRACE_WARNING)
80TRACELOG_CB(TRACE_NOTICE)
81TRACELOG_CB(TRACE_INFO)
82TRACELOG_CB(TRACE_DEBUG_SYSTEM)
83TRACELOG_CB(TRACE_DEBUG_PROGRAM)
84TRACELOG_CB(TRACE_DEBUG_PROCESS)
85TRACELOG_CB(TRACE_DEBUG_MODULE)
86TRACELOG_CB(TRACE_DEBUG_UNIT)
87TRACELOG_CB(TRACE_DEBUG_FUNCTION)
88TRACELOG_CB(TRACE_DEBUG_LINE)
89TRACELOG_CB(TRACE_DEBUG)
This page took 0.033221 seconds and 4 git commands to generate.