Move to kernel style SPDX license identifiers
[lttng-ust.git] / doc / examples / demo-tracelog / demo-vtracelog.c
CommitLineData
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
14void print_err(const char* msg, ...)
15{
16 va_list ap;
17
18 va_start(ap, msg);
19 vtracelog(TRACE_ERR, msg, ap);
20 va_end(ap);
21}
22
23int main(int argc, char **argv)
24{
25 int i;
26 int delay = 0;
27 const char *str = "mystring test";
28 long l = 0x42;
29
30 if (argc > 2)
31 delay = atoi(argv[1]);
32
33 fprintf(stderr, "Demo program starting.\n");
34
35 sleep(delay);
36
37 fprintf(stderr, "Tracing... ");
38
39 for (i = 0; i < 5; i++) {
40 print_err("This is a \"%s\" formatted %d error event %lx", str, i, l);
41 }
42
43 fprintf(stderr, " done.\n");
44 return 0;
45}
This page took 0.024333 seconds and 4 git commands to generate.