8 lttng_ust_tracelog, lttng_ust_vtracelog - LTTng-UST printf(3)-like interface with a log level
14 *#include <lttng/tracelog.h>*
17 #define *lttng_ust_tracelog*('level', 'fmt', ...)
18 #define *lttng_ust_vtracelog*('level', 'fmt', 'ap')
23 * If you define `_LGPL_SOURCE` before including
24 `<lttng/tracelog.h>` (directly or indirectly): `-llttng-ust-common`
28 The LTTng-UST `lttng_ust_tracelog()` and `lttng_ust_vtracelog()` API
29 allows you to trace your application with the help of simple
30 man:printf(3)-like and man:vprintf(3)-like macros, with an additional
31 parameter for the desired log level.
33 The 'fmt' argument is passed directly as the 'fmt' parameter of
34 man:vasprintf(3), as well as:
36 For `lttng_ust_tracelog()`::
37 The optional parameters following 'fmt'.
39 For `lttng_ust_vtracelog()`::
40 The 'ap' parameter as the 'ap' parameter of man:vasprintf(3)
43 The purpose of `lttng_ust_tracelog()` and `lttng_ust_vtracelog()` is to
44 ease the migration from logging to tracing.
46 The available values for the 'level' parameter are:
48 include::log-levels.txt[]
50 To use `lttng_ust_tracelog()` or `lttng_ust_vtracelog()`, include
51 `<lttng/tracelog.h>` where you need it, and link your application with
52 `liblttng-ust` and `liblttng-ust-common`. See the <<example,EXAMPLE>>
53 section below for a complete usage example.
55 Once your application is instrumented with `lttng_ust_tracelog()` and/or
56 `lttng_ust_vtracelog()` calls and ready to run, use
57 man:lttng-enable-event(1) to enable the `lttng_ust_tracelog:*` event.
58 You can isolate specific log levels with the nloption:--loglevel and
59 nloption:--loglevel-only options of this command.
61 The `lttng_ust_tracelog()` and `lttng_ust_vtracelog()` events contain
66 |Field name |Description
69 |Line in source file where `lttng_ust_tracelog()` was called.
72 |Source file from which `lttng_ust_tracelog()` was called.
75 |Function name from which `lttng_ust_tracelog()` was called.
78 |Formatted string output.
81 If you do not need to attach a specific log level to a
82 `lttng_ust_tracelog()`/`lttng_ust_vtracelog()` call, use
83 man:lttng_ust_tracef(3) instead.
85 See also the <<limitations,LIMITATIONS>> section below for important
86 limitations to consider when using `lttng_ust_tracelog()` or
87 `lttng_ust_vtracelog()`.
93 Here's a usage example of `lttng_ust_tracelog()`:
95 -------------------------------------------------------------------
97 #include <lttng/tracelog.h>
99 int main(int argc, char *argv[])
104 lttng_ust_tracelog(LTTNG_UST_TRACEPOINT_LOGLEVEL_CRIT,
105 "Not enough arguments: %d", argc);
109 lttng_ust_tracelog(LTTNG_UST_TRACEPOINT_LOGLEVEL_INFO,
110 "Starting app with %d arguments", argc);
112 for (i = 0; i < argc; i++) {
113 lttng_ust_tracelog(LTTNG_UST_TRACEPOINT_LOGLEVEL_DEBUG,
114 "Argument %d: %s", i, argv[i]);
117 lttng_ust_tracelog(LTTNG_UST_TRACEPOINT_LOGLEVEL_INFO,
121 -------------------------------------------------------------------
123 This C source file, saved as `app.c`, can be compiled into a program
128 $ cc -o app app.c -llttng-ust -llttng-ust-common
131 You can create an LTTng tracing session, enable all the
132 `lttng_ust_tracelog()` events, and start the created tracing session
137 $ lttng create my-session
138 $ lttng enable-event --userspace 'lttng_ust_tracelog:*'
142 Or you can enable `lttng_ust_tracelog()` events matching a log level at
143 least as severe as a given log level:
147 $ lttng enable-event --userspace 'lttng_ust_tracelog:*' \
151 Next, start the program to be traced:
155 $ ./app a few arguments passed to this application
158 Finally, stop the tracing session, and inspect the recorded events:
170 :macro-suffix: tracelog
172 include::tracef-tracelog-limitations.txt[]
175 include::common-footer.txt[]
177 include::common-copyrights.txt[]
179 include::common-authors.txt[]
184 man:lttng_ust_tracef(3),
185 man:lttng_ust_vtracef(3),