doc_examples_demodir = ${docdir}/examples/demo
doc_examples_hello_static_libdir = ${docdir}/examples/hello-static-lib
doc_examples_demo_tracefdir = ${docdir}/examples/demo-tracef
+doc_examples_demo_tracelogdir = ${docdir}/examples/demo-tracelog
doc_examples_clock_overridedir = ${docdir}/examples/clock-override
doc_examples_getcpu_overridedir = ${docdir}/examples/getcpu-override
demo-tracef/demo-tracef.c \
demo-tracef/README
+dist_doc_examples_demo_tracelog_DATA = demo-tracelog/Makefile \
+ demo-tracelog/demo-tracelog.c \
+ demo-tracelog/README
+
dist_doc_examples_clock_override_DATA = clock-override/Makefile \
clock-override/lttng-ust-clock-override-example.c \
clock-override/run-clock-override \
else
# Copies are for VPATH build support
SUBDIRS_PROXY = easy-ust demo hello-static-lib demo-tracef clock-override \
- getcpu-override
+ getcpu-override demo-tracelog
if BUILD_GEN_TP_EXAMPLES
SUBDIRS_PROXY += gen-tp
--- /dev/null
+# Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+# Copyright (C) 2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+#
+# THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
+# OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
+#
+# Permission is hereby granted to use or copy this program for any
+# purpose, provided the above notices are retained on all copies.
+# Permission to modify the code and to distribute modified code is
+# granted, provided the above notices are retained, and a notice that
+# the code was modified is included with the above copyright notice.
+#
+# This Makefile is not using automake so that users may see how to build
+# a program with tracepoint provider probes as stand-alone shared objects.
+#
+# This makefile is purposefully kept simple to support GNU and BSD make.
+
+ifdef AM_CC
+ CC = $(AM_CC)
+endif
+
+LIBS = -ldl -llttng-ust # On Linux
+#LIBS = -lc # On BSD
+LOCAL_CPPFLAGS += -I.
+
+all: demo-tracelog
+
+demo-tracelog.o: demo-tracelog.c
+ $(CC) $(CPPFLAGS) $(LOCAL_CPPFLAGS) $(CFLAGS) $(AM_CPPFLAGS) \
+ $(AM_CFLAGS) -c -o $@ $<
+
+demo-tracelog: demo-tracelog.o
+ $(CC) $(LDFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(AM_CFLAGS) \
+ -o $@ $< $(LIBS)
+
+.PHONY: clean
+clean:
+ rm -f *.o *.a demo-tracelog
--- /dev/null
+This is a demo application showing how to trace logging statements into
+LTTng-UST.
+
+The simplest commands to trace the demo program are:
+
+lttng create
+lttng enable-event -u "lttng_ust_tracelog:*"
+lttng start
+./demo-tracelog
+lttng stop
+lttng view
+lttng destroy
+
+The resulting lttng view output should look like this:
+
+[15:54:19.454863179] (+?.?????????) thinkos lttng_ust_tracelog:err: { cpu_id = 0 }, { line = 45, file = "demo-tracelog.c", func = "main", _msg_length = 17, msg = "Error condition 0" }
+[15:54:19.454871660] (+0.000008481) thinkos lttng_ust_tracelog:err: { cpu_id = 0 }, { line = 45, file = "demo-tracelog.c", func = "main", _msg_length = 17, msg = "Error condition 1" }
+[15:54:19.454872838] (+0.000001178) thinkos lttng_ust_tracelog:err: { cpu_id = 0 }, { line = 45, file = "demo-tracelog.c", func = "main", _msg_length = 17, msg = "Error condition 2" }
+[15:54:19.454873541] (+0.000000703) thinkos lttng_ust_tracelog:err: { cpu_id = 0 }, { line = 45, file = "demo-tracelog.c", func = "main", _msg_length = 17, msg = "Error condition 3" }
+[15:54:19.454874283] (+0.000000742) thinkos lttng_ust_tracelog:err: { cpu_id = 0 }, { line = 45, file = "demo-tracelog.c", func = "main", _msg_length = 17, msg = "Error condition 4" }
--- /dev/null
+/*
+ * Copyright (C) 2009 Pierre-Marc Fournier
+ * Copyright (C) 2011-2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; version 2.1 of
+ * the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <lttng/tracelog.h>
+
+int main(int argc, char **argv)
+{
+ int i;
+ int delay = 0;
+
+ if (argc == 2)
+ delay = atoi(argv[1]);
+
+ fprintf(stderr, "Demo program starting.\n");
+
+ sleep(delay);
+
+ fprintf(stderr, "Tracing... ");
+ for (i = 0; i < 5; i++) {
+ tracelog(err, "Error condition %d", i);
+ }
+ fprintf(stderr, " done.\n");
+ return 0;
+}