doc/man: only mention `-llttng-ust-common` in synopses (conditionally)
[lttng-ust.git] / doc / man / lttng_ust_tracef.3.txt
CommitLineData
5b1163c6
PP
1lttng_ust_tracef(3)
2===================
3:object-type: macro
4
5
6NAME
7----
8lttng_ust_tracef, lttng_ust_vtracef - LTTng-UST printf(3)-like interface
9
10
11SYNOPSIS
12--------
13[verse]
14*#include <lttng/tracef.h>*
15
16[verse]
17#define *lttng_ust_tracef*('fmt', ...)
18#define *lttng_ust_vtracef*('fmt', 'ap')
19
e9f549af
PP
20Link with:
21
22* `-llttng-ust`
23* If you define `_LGPL_SOURCE` before including
24 `<lttng/tracef.h>` (directly or indirectly): `-llttng-ust-common`
5b1163c6
PP
25
26
27DESCRIPTION
28-----------
29The LTTng-UST `lttng_ust_tracef()` and `lttng_ust_vtracef()` API allows
30you to trace your application with the help of simple man:printf(3)-like
31and man:vprintf(3)-like macros.
32
33The 'fmt' argument is passed directly as the 'fmt' parameter of
34man:vasprintf(3), as well as:
35
36For `lttng_ust_tracef()`::
37 The optional parameters following 'fmt'.
38
39For `lttng_ust_vtracef()`::
40 The 'ap' parameter as the 'ap' parameter of man:vasprintf(3)
41 (`va_list` type).
42
43To use `lttng_ust_tracef()` or `lttng_ust_vtracef()`, include
44`<lttng/tracef.h>` where you need it, and link your application with
45`liblttng-ust` and `liblttng-ust-common`. See the <<example,EXAMPLE>>
46section below for a complete usage example.
47
48Once your application is instrumented with `lttng_ust_tracef()` and/or
49`lttng_ust_vtracef()` calls and ready to run, use
50man:lttng-enable-event(1) to enable the `lttng_ust_tracef:*` event.
51
52The `lttng_ust_tracef()` and `lttng_ust_vtracef()` events contain a
53single field, named `msg`, which is the formatted string output.
54
55If you need to attach a specific log level to a
56`lttng_ust_tracef()`/`lttng_ust_vtracef()` call, use
57man:lttng_ust_tracelog(3) and man:lttng_ust_vtracelog(3) instead.
58
59See also the <<limitations,LIMITATIONS>> section below for important
60limitations to consider when using `lttng_ust_tracef()` or
61`lttng_ust_vtracef()`.
62
63
64[[example]]
65EXAMPLE
66-------
67Here's a usage example of `lttng_ust_tracef()`:
68
69-------------------------------------------------------------------
70#include <stdlib.h>
71#include <lttng/tracef.h>
72
73int main(void)
74{
75 int i;
76
77 for (i = 0; i < 25; i++) {
78 lttng_ust_tracef("my message: %s, this integer: %d",
79 "a message", i);
80 }
81
82 return EXIT_SUCCESS;
83}
84-------------------------------------------------------------------
85
86This C source file, saved as `app.c`, can be compiled into a program
87like this:
88
89[role="term"]
90----
91$ cc -o app app.c -llttng-ust -llttng-ust-common
92----
93
94You can create an LTTng tracing session, enable the `lttng_ust_tracef()`
95events, and start the created tracing session like this:
96
97[role="term"]
98----
99$ lttng create my-session
100$ lttng enable-event --userspace 'lttng_ust_tracef:*'
101$ lttng start
102----
103
104Next, start the program to be traced:
105
106[role="term"]
107----
108$ ./app
109----
110
111Finally, stop the tracing session, and inspect the recorded events:
112
113[role="term"]
114----
115$ lttng stop
116$ lttng view
117----
118
119
120[[limitations]]
121LIMITATIONS
122-----------
123:macro-suffix: tracef
124
125include::tracef-tracelog-limitations.txt[]
126
127
128include::common-footer.txt[]
129
130include::common-copyrights.txt[]
131
132include::common-authors.txt[]
133
134
135SEE ALSO
136--------
137man:lttng_ust_tracelog(3),
138man:lttng_ust_vtracelog(3),
139man:lttng-ust(3),
140man:lttng(1),
141man:printf(3)
This page took 0.027881 seconds and 4 git commands to generate.