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