Rename "tsc" to "timestamp"
[lttng-ust.git] / doc / examples / demo-tracef / demo-vtracef.c
1 /*
2 * SPDX-License-Identifier: LGPL-2.1-only
3 *
4 * Copyright (C) 2020 Maxime Roussin-Belanger <maxime.roussinbelanger@gmail.com>
5 */
6
7 #include <stdarg.h>
8 #include <stdlib.h>
9 #include <stdio.h>
10 #include <unistd.h>
11
12 #include <lttng/tracef.h>
13
14 static
15 void print_debug(const char* msg, ...)
16 __attribute__((format(printf, 1, 2)));
17 static
18 void print_debug(const char* msg, ...)
19 {
20 va_list ap;
21
22 va_start(ap, msg);
23 lttng_ust_vtracef(msg, ap);
24 va_end(ap);
25 }
26
27 int main(int argc, char **argv)
28 {
29 int i;
30 int delay = 0;
31 const char *str = "mystring test";
32 long l = 0x42;
33
34 if (argc > 2)
35 delay = atoi(argv[1]);
36
37 fprintf(stderr, "Demo program starting.\n");
38
39 sleep(delay);
40
41 fprintf(stderr, "Tracing... ");
42
43 for (i = 0; i < 5; i++) {
44 print_debug("This is a \"%s\" formatted %d event %lx", str, i, l);
45 }
46
47 fprintf(stderr, " done.\n");
48 return 0;
49 }
This page took 0.038932 seconds and 5 git commands to generate.