NAME
lttng_ust_tracelog, lttng_ust_vtracelog - LTTng-UST printf(3)-like interface with a log levelSYNOPSIS
#include <lttng/tracelog.h>
#define lttng_ust_tracelog(level, fmt, ...) #define lttng_ust_vtracelog(level, fmt, ap)
•-llttng-ust
•If you define _LGPL_SOURCE
before including <lttng/tracelog.h> (directly or indirectly):
-llttng-ust-common
DESCRIPTION
The LTTng-UST lttng_ust_tracelog() and lttng_ust_vtracelog() API allows you to trace your application with the help of simple printf(3)-like and vprintf(3)-like macros, with an additional parameter for the desired log level.The optional parameters following
fmt.
For lttng_ust_vtracelog()
The ap parameter as the ap
parameter of vasprintf(3) ( va_list type).
System is unusable.
LTTNG_UST_TRACEPOINT_LOGLEVEL_ALERT
Action must be taken immediately.
LTTNG_UST_TRACEPOINT_LOGLEVEL_CRIT
Critical conditions.
LTTNG_UST_TRACEPOINT_LOGLEVEL_ERR
Error conditions.
LTTNG_UST_TRACEPOINT_LOGLEVEL_WARNING
Warning conditions.
LTTNG_UST_TRACEPOINT_LOGLEVEL_NOTICE
Normal, but significant, condition.
LTTNG_UST_TRACEPOINT_LOGLEVEL_INFO
Informational message.
LTTNG_UST_TRACEPOINT_LOGLEVEL_DEBUG_SYSTEM
Debug information with system-level scope (set
of programs).
LTTNG_UST_TRACEPOINT_LOGLEVEL_DEBUG_PROGRAM
Debug information with program-level scope
(set of processes).
LTTNG_UST_TRACEPOINT_LOGLEVEL_DEBUG_PROCESS
Debug information with process-level scope
(set of modules).
LTTNG_UST_TRACEPOINT_LOGLEVEL_DEBUG_MODULE
Debug information with module
(executable/library) scope (set of units).
LTTNG_UST_TRACEPOINT_LOGLEVEL_DEBUG_UNIT
Debug information with compilation unit scope
(set of functions).
LTTNG_UST_TRACEPOINT_LOGLEVEL_DEBUG_FUNCTION
Debug information with function-level
scope.
LTTNG_UST_TRACEPOINT_LOGLEVEL_DEBUG_LINE
Debug information with line-level scope
(default log level).
LTTNG_UST_TRACEPOINT_LOGLEVEL_DEBUG
Debug-level message.
Field name | Description |
line | Line in source file where lttng_ust_tracelog() was called. |
file | Source file from which lttng_ust_tracelog() was called. |
func | Function name from which lttng_ust_tracelog() was called. |
msg | Formatted string output. |
EXAMPLE
Here’s a usage example of lttng_ust_tracelog():#include <stdlib.h> #include <lttng/tracelog.h> int main(int argc, char *argv[]) { int i; if (argc < 2) { lttng_ust_tracelog(LTTNG_UST_TRACEPOINT_LOGLEVEL_CRIT, "Not enough arguments: %d", argc); return EXIT_FAILURE; } lttng_ust_tracelog(LTTNG_UST_TRACEPOINT_LOGLEVEL_INFO, "Starting app with %d arguments", argc); for (i = 0; i < argc; i++) { lttng_ust_tracelog(LTTNG_UST_TRACEPOINT_LOGLEVEL_DEBUG, "Argument %d: %s", i, argv[i]); } lttng_ust_tracelog(LTTNG_UST_TRACEPOINT_LOGLEVEL_INFO, "Exiting app"); return EXIT_SUCCESS; }
$ cc -o app app.c -llttng-ust -llttng-ust-common
$ lttng create my-session $ lttng enable-event --userspace 'lttng_ust_tracelog:*' $ lttng start
$ lttng enable-event --userspace 'lttng_ust_tracelog:*' \ --loglevel=INFO
$ ./app a few arguments passed to this application
$ lttng stop $ lttng view
LIMITATIONS
The lttng_ust_tracelog() and lttng_ust_vtracelog() utility macros were developed to make user space tracing super simple, albeit with notable disadvantages compared to custom, full-fledged tracepoint providers:•All generated events have the same
provider/event names.
•There’s no static type
checking.
•The only event field with user data
you actually get, named msg, is a string potentially containing the
values you passed to the macro using your own format. This also means that you
cannot use filtering using a custom expression at run time because there are
no isolated fields.
•Since lttng_ust_tracelog() and
lttng_ust_vtracelog() use C standard library’s
vasprintf(3) function in the background to format the strings at run
time, their expected performance is lower than using custom tracepoint
providers with typed fields, which do not require a conversion to a
string.
•Generally, a string containing the
textual representation of the user data fields is not as compact as binary
fields in the resulting trace.
BUGS
If you encounter any issue or usability problem, please report it on the LTTng bug tracker <https://bugs.lttng.org/projects/lttng-ust>.RESOURCES
•LTTng project website
<http://lttng.org>
•LTTng documentation
<http://lttng.org/docs>
•Git repositories
<http://git.lttng.org>
•GitHub organization
<http://github.com/lttng>
•Continuous integration
<http://ci.lttng.org/>
•Mailing list
<http://lists.lttng.org> for support and development:
[email protected]
•IRC channel
<irc://irc.oftc.net/lttng>: #lttng on irc.oftc.net
COPYRIGHTS
This macro is part of the LTTng-UST project.THANKS
Thanks to Ericsson for funding this work, providing real-life use cases, and testing.AUTHORS
LTTng-UST was originally written by Mathieu Desnoyers, with additional contributions from various other people. It is currently maintained by Mathieu Desnoyers <mailto:[email protected]>.SEE ALSO
lttng_ust_tracef(3), lttng_ust_vtracef(3), lttng-ust(3), lttng(1), printf(3)09/30/2022 | LTTng 2.13.5 |