| 1 | /* |
| 2 | * Copyright (C) 2020 Maxime Roussin-Belanger <maxime.roussinbelanger@gmail.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/tracef.h> |
| 25 | |
| 26 | void print_debug(const char* msg, ...) |
| 27 | { |
| 28 | va_list ap; |
| 29 | |
| 30 | va_start(ap, msg); |
| 31 | vtracef(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_debug("This is a \"%s\" formatted %d event %lx", str, i, l); |
| 53 | } |
| 54 | |
| 55 | fprintf(stderr, " done.\n"); |
| 56 | return 0; |
| 57 | } |