Commit | Line | Data |
---|---|---|
0cb03c85 | 1 | /* |
c0c0989a | 2 | * SPDX-License-Identifier: MIT |
0cb03c85 | 3 | * |
c0c0989a | 4 | * Copyright (C) 2013-2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
0cb03c85 MD |
5 | */ |
6 | ||
c0c0989a MJ |
7 | #ifndef _LTTNG_UST_TRACELOG_H |
8 | #define _LTTNG_UST_TRACELOG_H | |
9 | ||
1698631b | 10 | #include <lttng/ust-api-compat.h> |
b15c4010 | 11 | #include <lttng/tp/lttng-ust-tracelog.h> |
0cb03c85 MD |
12 | |
13 | #ifdef __cplusplus | |
14 | extern "C" { | |
15 | #endif | |
16 | ||
1698631b MJ |
17 | #define LTTNG_UST_TP_TRACELOG_CB_TEMPLATE(level) \ |
18 | extern void lttng_ust__tracelog_##level(const char *file, \ | |
4199ddc7 MJ |
19 | int line, const char *func, const char *fmt, ...) \ |
20 | __attribute__ ((format(printf, 4, 5))); \ | |
21 | \ | |
1698631b | 22 | extern void lttng_ust__vtracelog_##level(const char *file, \ |
4199ddc7 MJ |
23 | int line, const char *func, const char *fmt, \ |
24 | va_list ap) \ | |
25 | __attribute__ ((format(printf, 4, 0))); | |
0cb03c85 | 26 | |
1698631b MJ |
27 | LTTNG_UST_TP_TRACELOG_CB_TEMPLATE(LTTNG_UST_TRACEPOINT_LOGLEVEL_EMERG); |
28 | LTTNG_UST_TP_TRACELOG_CB_TEMPLATE(LTTNG_UST_TRACEPOINT_LOGLEVEL_ALERT); | |
29 | LTTNG_UST_TP_TRACELOG_CB_TEMPLATE(LTTNG_UST_TRACEPOINT_LOGLEVEL_CRIT); | |
30 | LTTNG_UST_TP_TRACELOG_CB_TEMPLATE(LTTNG_UST_TRACEPOINT_LOGLEVEL_ERR); | |
31 | LTTNG_UST_TP_TRACELOG_CB_TEMPLATE(LTTNG_UST_TRACEPOINT_LOGLEVEL_WARNING); | |
32 | LTTNG_UST_TP_TRACELOG_CB_TEMPLATE(LTTNG_UST_TRACEPOINT_LOGLEVEL_NOTICE); | |
33 | LTTNG_UST_TP_TRACELOG_CB_TEMPLATE(LTTNG_UST_TRACEPOINT_LOGLEVEL_INFO); | |
34 | LTTNG_UST_TP_TRACELOG_CB_TEMPLATE(LTTNG_UST_TRACEPOINT_LOGLEVEL_DEBUG_SYSTEM); | |
35 | LTTNG_UST_TP_TRACELOG_CB_TEMPLATE(LTTNG_UST_TRACEPOINT_LOGLEVEL_DEBUG_PROGRAM); | |
36 | LTTNG_UST_TP_TRACELOG_CB_TEMPLATE(LTTNG_UST_TRACEPOINT_LOGLEVEL_DEBUG_PROCESS); | |
37 | LTTNG_UST_TP_TRACELOG_CB_TEMPLATE(LTTNG_UST_TRACEPOINT_LOGLEVEL_DEBUG_MODULE); | |
38 | LTTNG_UST_TP_TRACELOG_CB_TEMPLATE(LTTNG_UST_TRACEPOINT_LOGLEVEL_DEBUG_UNIT); | |
39 | LTTNG_UST_TP_TRACELOG_CB_TEMPLATE(LTTNG_UST_TRACEPOINT_LOGLEVEL_DEBUG_FUNCTION); | |
40 | LTTNG_UST_TP_TRACELOG_CB_TEMPLATE(LTTNG_UST_TRACEPOINT_LOGLEVEL_DEBUG_LINE); | |
41 | LTTNG_UST_TP_TRACELOG_CB_TEMPLATE(LTTNG_UST_TRACEPOINT_LOGLEVEL_DEBUG); | |
42 | ||
43 | #undef LTTNG_UST_TP_TRACELOG_CB_TEMPLATE | |
44 | ||
45 | #define lttng_ust_tracelog(level, fmt, ...) \ | |
0cb03c85 | 46 | do { \ |
b88f9167 | 47 | LTTNG_UST_STAP_PROBEV(tracepoint_lttng_ust_tracelog, level, ## __VA_ARGS__); \ |
0274f7f2 | 48 | if (caa_unlikely(lttng_ust_tracepoint_lttng_ust_tracelog___##level.state)) \ |
1698631b | 49 | lttng_ust__tracelog_##level(__FILE__, __LINE__, __func__, \ |
49faeca7 | 50 | fmt, ## __VA_ARGS__); \ |
0cb03c85 MD |
51 | } while (0) |
52 | ||
1698631b | 53 | #define lttng_ust_vtracelog(level, fmt, ap) \ |
bd9bb3c7 | 54 | do { \ |
0274f7f2 | 55 | if (caa_unlikely(lttng_ust_tracepoint_lttng_ust_tracelog___##level.state)) \ |
1698631b | 56 | lttng_ust__vtracelog_##level(__FILE__, __LINE__, __func__, \ |
49faeca7 | 57 | fmt, ap); \ |
bd9bb3c7 MRB |
58 | } while (0) |
59 | ||
1698631b MJ |
60 | #if LTTNG_UST_COMPAT_API(0) |
61 | #define TP_TRACELOG_CB_TEMPLATE LTTNG_UST_TP_TRACELOG_CB_TEMPLATE | |
62 | #define tracelog lttng_ust_tracelog | |
1698631b MJ |
63 | #endif |
64 | ||
0cb03c85 MD |
65 | #ifdef __cplusplus |
66 | } | |
67 | #endif | |
68 | ||
69 | #endif /* _LTTNG_UST_TRACELOG_H */ |