Commit | Line | Data |
---|---|---|
37175ce4 | 1 | /* |
9d16b343 MJ |
2 | * Copyright (C) 2015 Michael Jeanson <mjeanson@efficios.com> |
3 | * Copyright (C) 2013 David Goulet <dgoulet@efficios.com> | |
37175ce4 | 4 | * |
9d16b343 | 5 | * SPDX-License-Identifier: GPL-2.0-only |
37175ce4 | 6 | * |
37175ce4 DG |
7 | */ |
8 | ||
0b7af945 | 9 | import java.io.IOException; |
37175ce4 | 10 | import java.lang.Integer; |
0b7af945 | 11 | import java.util.logging.Handler; |
37175ce4 | 12 | import java.util.logging.Logger; |
88f54ca9 | 13 | import java.util.logging.Level; |
37175ce4 | 14 | |
0b7af945 | 15 | import org.lttng.ust.agent.jul.LttngLogHandler; |
37175ce4 | 16 | |
0b7af945 MJ |
17 | public class JTestLTTng { |
18 | ||
19 | /** | |
20 | * Application start | |
21 | * | |
22 | * @param args | |
23 | * Command-line arguments | |
24 | * @throws IOException | |
25 | * @throws InterruptedException | |
26 | */ | |
27 | public static void main(String args[]) throws IOException, InterruptedException { | |
37175ce4 | 28 | |
37175ce4 | 29 | Logger lttng = Logger.getLogger("JTestLTTng"); |
9b21e6d5 | 30 | Logger lttng2 = Logger.getLogger("JTestLTTng2"); |
0b7af945 | 31 | |
37175ce4 DG |
32 | int nrIter = Integer.parseInt(args[0]); |
33 | int waitTime = Integer.parseInt(args[1]); | |
9b21e6d5 DG |
34 | int fire_finest_tp = 0; |
35 | int fire_second_tp = 0; | |
36 | ||
37 | if (args.length > 2) { | |
38 | fire_finest_tp = Integer.parseInt(args[2]); | |
39 | } | |
40 | if (args.length > 3) { | |
41 | fire_second_tp = Integer.parseInt(args[3]); | |
42 | } | |
37175ce4 | 43 | |
0b7af945 MJ |
44 | /* Instantiate a LTTngLogHandler object, and attach it to our loggers */ |
45 | Handler lttngHandler = new LttngLogHandler(); | |
46 | lttng.addHandler(lttngHandler); | |
47 | lttng2.addHandler(lttngHandler); | |
48 | ||
88f54ca9 | 49 | lttng.setLevel(Level.FINEST); |
37175ce4 DG |
50 | |
51 | for (int iter = 0; iter < nrIter; iter++) { | |
52 | lttng.info("JUL tp fired!"); | |
9b21e6d5 | 53 | if (fire_finest_tp == 1) { |
88f54ca9 DG |
54 | /* Third arg, trigger finest TP. */ |
55 | lttng.finest("JUL FINEST tp fired"); | |
56 | } | |
37175ce4 DG |
57 | Thread.sleep(waitTime); |
58 | } | |
59 | ||
9b21e6d5 DG |
60 | if (fire_second_tp == 1) { |
61 | lttng2.info("JUL second logger fired"); | |
62 | } | |
63 | ||
0b7af945 MJ |
64 | /* |
65 | * Do not forget to close() all handlers so that the agent can shutdown | |
66 | * and the session daemon socket gets cleaned up explicitly. | |
67 | */ | |
68 | lttngHandler.close(); | |
37175ce4 DG |
69 | } |
70 | } |