Commit | Line | Data |
---|---|---|
bd9bb3c7 | 1 | /* |
c0c0989a | 2 | * SPDX-License-Identifier: LGPL-2.1-only |
bd9bb3c7 | 3 | * |
c0c0989a | 4 | * Copyright (C) 2020 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
bd9bb3c7 MRB |
5 | */ |
6 | ||
7 | #include <stdarg.h> | |
8 | #include <stdlib.h> | |
9 | #include <stdio.h> | |
10 | #include <unistd.h> | |
11 | ||
12 | #include <lttng/tracelog.h> | |
13 | ||
4199ddc7 MJ |
14 | static |
15 | void print_err(const char* msg, ...) | |
16 | __attribute__((format(printf, 1, 2))); | |
17 | static | |
bd9bb3c7 MRB |
18 | void print_err(const char* msg, ...) |
19 | { | |
20 | va_list ap; | |
21 | ||
22 | va_start(ap, msg); | |
1698631b | 23 | lttng_ust_vtracelog(LTTNG_UST_TRACEPOINT_LOGLEVEL_ERR, msg, ap); |
bd9bb3c7 MRB |
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_err("This is a \"%s\" formatted %d error event %lx", str, i, l); | |
45 | } | |
46 | ||
47 | fprintf(stderr, " done.\n"); | |
48 | return 0; | |
49 | } |