c3e604ce2aaec2f60de4c2f21fb02429a55bfa81
[lttng-ust.git] / doc / examples / demo-tracelog / demo-vtracelog.c
1 /*
2 * Copyright (C) 2020 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; version 2.1 of
7 * the License.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 #include <stdarg.h>
20 #include <stdlib.h>
21 #include <stdio.h>
22 #include <unistd.h>
23
24 #include <lttng/tracelog.h>
25
26 void print_err(const char* msg, ...)
27 {
28 va_list ap;
29
30 va_start(ap, msg);
31 vtracelog(TRACE_ERR, msg, ap);
32 va_end(ap);
33 }
34
35 int main(int argc, char **argv)
36 {
37 int i;
38 int delay = 0;
39 const char *str = "mystring test";
40 long l = 0x42;
41
42 if (argc > 2)
43 delay = atoi(argv[1]);
44
45 fprintf(stderr, "Demo program starting.\n");
46
47 sleep(delay);
48
49 fprintf(stderr, "Tracing... ");
50
51 for (i = 0; i < 5; i++) {
52 print_err("This is a \"%s\" formatted %d error event %lx", str, i, l);
53 }
54
55 fprintf(stderr, " done.\n");
56 return 0;
57 }
This page took 0.030026 seconds and 3 git commands to generate.