8 tracef - LTTng-UST printf(3)-like interface
14 *#include <lttng/tracef.h>*
17 #define *tracef*('fmt', ...)
19 Link with `-llttng-ust`.
24 The LTTng-UST `tracef()` API allows you to trace your application with
25 the help of a simple man:printf(3)-like macro. The 'fmt' argument is
26 passed directly to the 'fmt' parameter of man:vasprintf(3), as well as
27 the optional parameters following 'fmt'.
29 To use `tracef()`, include `<lttng/tracef.h>` where you need it, and
30 link your application with `liblttng-ust`. See the <<example,EXAMPLE>>
31 section below for a complete usage example.
33 Once your application is instrumented with `tracef()` calls and
34 ready to run, use man:lttng-enable-event(1) to enable the
35 `lttng_ust_tracef:*` event.
37 The `tracef()` events contain a single field, named `msg`, which is the
38 formatted string output.
40 If you need to attach a specific log level to a `tracef()` call, use
41 man:tracelog(3) instead.
43 See also the <<limitations,LIMITATIONS>> section below for important
44 limitations to consider when using `tracef()`.
50 Here's a usage example of `tracef()`:
52 -------------------------------------------------------------------
54 #include <lttng/tracef.h>
60 for (i = 0; i < 25; i++) {
61 tracef("my message: %s, this integer: %d", "a message", i);
66 -------------------------------------------------------------------
68 This C source file, saved as `app.c`, can be compiled into a program
72 ---------------------------
73 cc -o app app.c -llttng-ust
74 ---------------------------
76 You can create an LTTng tracing session, enable the `tracef()` events,
77 and start the created tracing session like this:
80 ---------------------------------------------------
81 lttng create my-session
82 lttng enable-event --userspace 'lttng_ust_tracef:*'
84 ---------------------------------------------------
86 Next, start the program to be traced:
93 Finally, stop the tracing session, and inspect the recorded events:
107 include::tracef-tracelog-limitations.txt[]
110 include::common-footer.txt[]
112 include::common-copyrights.txt[]
114 include::common-authors.txt[]