Document tracelog() facility
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 4 Sep 2015 21:48:27 +0000 (17:48 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Sat, 5 Sep 2015 01:52:32 +0000 (21:52 -0400)
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
contents/using-lttng/instrumenting/c-application/tracelog.md [new file with mode: 0644]
toc/docs.yml

diff --git a/contents/using-lttng/instrumenting/c-application/tracelog.md b/contents/using-lttng/instrumenting/c-application/tracelog.md
new file mode 100644 (file)
index 0000000..c99b31b
--- /dev/null
@@ -0,0 +1,61 @@
+---
+id: tracelog
+since: 2.7
+---
+
+The `tracelog()` API is very similar to [`tracef()`](#doc-tracef). The
+only difference is that it accepts an additional log level parameter.
+
+The goal of `tracelog()` is to ease the migration from logging to
+tracing.
+
+Here's an example:
+
+~~~ c
+#include <lttng/tracelog.h>
+
+void my_function(int my_integer) {
+    /* ... */
+
+    tracelog(TRACE_INFO, "my message, my integer: %d", my_integer);
+
+    /* ... */
+}
+~~~
+
+See [LTTng-UST library reference](#doc-liblttng-ust-tracepoint-loglevel)
+for the list of available log level names.
+
+Link your application with `liblttng-ust`:
+
+<pre class="term">
+gcc -o app app.c <strong>-llttng-ust</strong>
+</pre>
+
+Execute the application as usual:
+
+<pre class="term">
+./app
+</pre>
+
+The events produced by `tracelog()` calls are prefixed with
+`lttng_ust_tracelog:`. To enable `tracelog()` events matching a range
+of log levels, do:
+
+<pre class="term">
+lttng enable-event --userspace 'lttng_ust_tracelog:*' \
+                   --loglevel TRACE_INFO
+</pre>
+
+This enables all `tracelog()` events with a log level at least as important
+as `TRACE_INFO`.
+
+To enable `tracelog()` events matching a specific log level, do:
+
+<pre class="term">
+lttng enable-event --userspace 'lttng_ust_tracelog:*' \
+                   --loglevel-only TRACE_WARNING
+</pre>
+
+See [Enabling and disabling events](#doc-enabling-disabling-events) for
+more options.
index 39b13c7c2ed8c8db9ce3d42371c1a668a184f5f2..291cc979b992573816f06ab353250fab87b0d5f0 100644 (file)
@@ -124,6 +124,8 @@ cats:
                     title: <span class="reset-text-transform">pkg-config</span>
               - id: tracef
                 title: Using <code>tracef()</code>
+              - id: tracelog
+                title: Using <code>tracelog()</code>
               - id: lttng-ust-environment-variables-compiler-flags
                 title: <span class="reset-text-transform">LTTng</span>-UST environment variables and special compilation flags
           - id: cxx-application
This page took 0.027288 seconds and 4 git commands to generate.