Tracepoint API namespacing '__tracepoint_'
[lttng-ust.git] / src / lib / lttng-ust / tracelog.c
1 /*
2 * SPDX-License-Identifier: MIT
3 *
4 * Copyright (C) 2013-2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5 */
6
7 #define _LGPL_SOURCE
8 #include <stdio.h>
9 #include "common/macros.h"
10
11 #define TRACEPOINT_CREATE_PROBES
12 #define TRACEPOINT_DEFINE
13 #include "lttng-ust-tracelog-provider.h"
14
15 #define TRACELOG_CB(level) \
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 \
23 void __lttng_ust_vtracelog_##level(const char *file, \
24 int line, const char *func, \
25 const char *fmt, va_list ap) \
26 { \
27 char *msg; \
28 const int len = vasprintf(&msg, fmt, ap); \
29 \
30 /* len does not include the final \0 */ \
31 if (len < 0) \
32 goto end; \
33 lttng_ust_tracepoint_cb_lttng_ust_tracelog___##level(file, \
34 line, func, msg, len, \
35 LTTNG_UST_CALLER_IP()); \
36 free(msg); \
37 end: \
38 return; \
39 } \
40 \
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 \
46 void _lttng_ust_vtracelog_##level(const char *file, \
47 int line, const char *func, \
48 const char *fmt, va_list ap); \
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 \
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 \
61 void _lttng_ust_tracelog_##level(const char *file, \
62 int line, const char *func, \
63 const char *fmt, ...); \
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); \
72 va_end(ap); \
73 }
74
75 TRACELOG_CB(TRACE_EMERG)
76 TRACELOG_CB(TRACE_ALERT)
77 TRACELOG_CB(TRACE_CRIT)
78 TRACELOG_CB(TRACE_ERR)
79 TRACELOG_CB(TRACE_WARNING)
80 TRACELOG_CB(TRACE_NOTICE)
81 TRACELOG_CB(TRACE_INFO)
82 TRACELOG_CB(TRACE_DEBUG_SYSTEM)
83 TRACELOG_CB(TRACE_DEBUG_PROGRAM)
84 TRACELOG_CB(TRACE_DEBUG_PROCESS)
85 TRACELOG_CB(TRACE_DEBUG_MODULE)
86 TRACELOG_CB(TRACE_DEBUG_UNIT)
87 TRACELOG_CB(TRACE_DEBUG_FUNCTION)
88 TRACELOG_CB(TRACE_DEBUG_LINE)
89 TRACELOG_CB(TRACE_DEBUG)
This page took 0.031596 seconds and 4 git commands to generate.