8 tracef, vtracef - LTTng-UST printf(3)-like interface
14 *#include <lttng/tracef.h>*
17 #define *tracef*('fmt', ...)
18 #define *vtracef*('fmt', 'va_list' ap)
20 Link with `-llttng-ust`.
25 The LTTng-UST `tracef()` API allows you to trace your application with
26 the help of a simple man:printf(3)-like macro. The 'fmt' argument is
27 passed directly to the 'fmt' parameter of man:vasprintf(3), as well as
28 the optional parameters following 'fmt'.
30 To use `tracef()` or `vtracef()`, include `<lttng/tracef.h>` where you need it,
31 and link your application with `liblttng-ust`. See the <<example,EXAMPLE>>
32 section below for a complete usage example.
34 Once your application is instrumented with `tracef()` or `vtracef()` calls and
35 ready to run, use man:lttng-enable-event(1) to enable the
36 `lttng_ust_tracef:*` event.
38 The `tracef()` events contain a single field, named `msg`, which is the
39 formatted string output.
41 If you need to attach a specific log level to a `tracef()` call, use
42 man:tracelog(3) instead.
44 See also the <<limitations,LIMITATIONS>> section below for important
45 limitations to consider when using `tracef()` or `vtracef()`.
51 Here's a usage example of `tracef()`:
53 -------------------------------------------------------------------
55 #include <lttng/tracef.h>
61 for (i = 0; i < 25; i++) {
62 tracef("my message: %s, this integer: %d", "a message", i);
67 -------------------------------------------------------------------
69 This C source file, saved as `app.c`, can be compiled into a program
74 $ cc -o app app.c -llttng-ust
77 You can create an LTTng tracing session, enable the `tracef()` events,
78 and start the created tracing session like this:
82 $ lttng create my-session
83 $ lttng enable-event --userspace 'lttng_ust_tracef:*'
87 Next, start the program to be traced:
94 Finally, stop the tracing session, and inspect the recorded events:
108 include::tracef-tracelog-limitations.txt[]
111 include::common-footer.txt[]
113 include::common-copyrights.txt[]
115 include::common-authors.txt[]