Tracepoint API namespacing tracelog
[lttng-ust.git] / doc / examples / demo-tracelog / demo-vtracelog.c
... / ...
CommitLineData
1/*
2 * SPDX-License-Identifier: LGPL-2.1-only
3 *
4 * Copyright (C) 2020 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
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
14static
15void print_err(const char* msg, ...)
16 __attribute__((format(printf, 1, 2)));
17static
18void print_err(const char* msg, ...)
19{
20 va_list ap;
21
22 va_start(ap, msg);
23 lttng_ust_vtracelog(LTTNG_UST_TRACEPOINT_LOGLEVEL_ERR, msg, ap);
24 va_end(ap);
25}
26
27int 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}
This page took 0.024187 seconds and 4 git commands to generate.