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