doc/man: add full stop to descriptive table cells
[lttng-ust.git] / doc / man / tracelog.3.txt
CommitLineData
4ddbd0b7
PP
1tracelog(3)
2===========
3:object-type: macro
4
5
6NAME
7----
0810c65b 8tracelog - LTTng-UST printf(3)-like interface with a log level
4ddbd0b7
PP
9
10
11SYNOPSIS
12--------
13[verse]
14*#include <lttng/tracelog.h>*
15
16[verse]
17#define *tracelog*('level', 'fmt', ...)
18
19Link with `-llttng-ust`.
20
21
22DESCRIPTION
23-----------
24The LTTng-UST `tracelog()` API allows you to trace your application with
25the help of a simple man:printf(3)-like macro, with an additional
26parameter for the desired log level. The 'fmt' argument is passed
27directly to the 'fmt' parameter of man:vasprintf(3), as well as
28the optional parameters following 'fmt'.
29
30The purpose of `tracelog()` is to ease the migration from logging to
31tracing.
32
33The available values for the 'level' parameter are:
34
35include::log-levels.txt[]
36
37To use `tracelog()`, include `<lttng/tracelog.h>` where you need it, and
38link your application with `liblttng-ust`. See the <<example,EXAMPLE>>
39section below for a complete usage example.
40
41Once your application is instrumented with `tracelog()` calls and
42ready to run, use man:lttng-enable-event(1) to enable the
43`lttng_ust_tracelog:*` event. You can isolate specific log levels with
44the nloption:--loglevel and nloption:--loglevel-only options of this
45command.
46
47The `tracelog()` events contain the following fields:
48
49[options="header"]
8902dadc
PP
50|===
51|Field name |Description
52
53|`line`
d01f365a 54|Line in source file where `tracelog()` was called.
8902dadc
PP
55
56|`file`
d01f365a 57|Source file from which `tracelog()` was called.
8902dadc
PP
58
59|`func`
d01f365a 60|Function name from which `tracelog()` was called.
8902dadc
PP
61
62|`msg`
d01f365a 63|Formatted string output.
8902dadc 64|===
4ddbd0b7
PP
65
66If you do not need to attach a specific log level to a `tracelog()`
67call, use man:tracef(3) instead.
68
69See also the <<limitations,LIMITATIONS>> section below for important
70limitations to consider when using `tracelog()`.
71
72
73[[example]]
74EXAMPLE
75-------
76Here's a usage example of `tracelog()`:
77
78-------------------------------------------------------------------
79#include <stdlib.h>
80#include <lttng/tracelog.h>
81
82int main(int argc, char *argv[])
83{
84 int i;
85
86 if (argc < 2) {
87 tracelog(TRACE_CRIT, "Not enough arguments: %d", argc);
88 return EXIT_FAILURE;
89 }
90
91 tracelog(TRACE_INFO, "Starting app with %d arguments", argc);
92
93 for (i = 0; i < argc; i++) {
94 tracelog(TRACE_DEBUG, "Argument %d: %s", i, argv[i]);
95 }
96
97 tracelog(TRACE_INFO, "Exiting app");
98
99 return EXIT_SUCCESS;
100}
101-------------------------------------------------------------------
102
103This C source file, saved as `app.c`, can be compiled into a program
104like this:
105
106[role="term"]
107---------------------------
108cc -o app app.c -llttng-ust
109---------------------------
110
111You can create an LTTng tracing session, enable all the `tracelog()`
112events, and start the created tracing session like this:
113
114[role="term"]
115---------------------------------------------------
116lttng create my-session
117lttng enable-event --userspace 'lttng_ust_tracelog:*'
118lttng start
119---------------------------------------------------
120
121Or you can enable `tracelog()` events matching a log level at least
122as severe as a given log level:
123
124[role="term"]
125-------------------------------------------------------
126lttng enable-event --userspace 'lttng_ust_tracelog:*' \
127 --loglevel=TRACE_INFO
128-------------------------------------------------------
129
130Next, start the program to be traced:
131
132[role="term"]
133------------------------------------------------
134./app a few arguments passed to this application
135------------------------------------------------
136
137Finally, stop the tracing session, and inspect the recorded events:
138
139[role="term"]
140----------
141lttng stop
142lttng view
143----------
144
145
146[[limitations]]
147LIMITATIONS
148-----------
149:macro-name: tracelog
150
151include::tracef-tracelog-limitations.txt[]
152
153
154include::common-footer.txt[]
155
156include::common-copyrights.txt[]
157
158include::common-authors.txt[]
159
160
161SEE ALSO
162--------
163man:tracef(3),
164man:lttng-ust(3),
165man:lttng(1),
166man:printf(3)
This page took 0.028376 seconds and 4 git commands to generate.