Commit | Line | Data |
---|---|---|
37175ce4 | 1 | /* |
0b7af945 | 2 | * Copyright (C) 2015 - Michael Jeanson <mjeanson@efficios.com> |
37175ce4 DG |
3 | * Copyright (C) 2013 - David Goulet <dgoulet@efficios.com> |
4 | * | |
5 | * This program is free software; you can redistribute it and/or modify it | |
6 | * under the terms of the GNU General Public License, version 2 only, as | |
7 | * published by the Free Software Foundation. | |
8 | * | |
9 | * This program is distributed in the hope that it will be useful, but WITHOUT | |
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
12 | * more details. | |
13 | * | |
14 | * You should have received a copy of the GNU General Public License along with | |
15 | * this program; if not, write to the Free Software Foundation, Inc., 51 | |
16 | * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
17 | */ | |
18 | ||
0b7af945 | 19 | import java.io.IOException; |
37175ce4 | 20 | import java.lang.Integer; |
0b7af945 | 21 | import java.util.logging.Handler; |
37175ce4 | 22 | import java.util.logging.Logger; |
88f54ca9 | 23 | import java.util.logging.Level; |
37175ce4 | 24 | |
0b7af945 | 25 | import org.lttng.ust.agent.jul.LttngLogHandler; |
37175ce4 | 26 | |
0b7af945 MJ |
27 | public class JTestLTTng { |
28 | ||
29 | /** | |
30 | * Application start | |
31 | * | |
32 | * @param args | |
33 | * Command-line arguments | |
34 | * @throws IOException | |
35 | * @throws InterruptedException | |
36 | */ | |
37 | public static void main(String args[]) throws IOException, InterruptedException { | |
37175ce4 | 38 | |
37175ce4 | 39 | Logger lttng = Logger.getLogger("JTestLTTng"); |
9b21e6d5 | 40 | Logger lttng2 = Logger.getLogger("JTestLTTng2"); |
0b7af945 | 41 | |
37175ce4 DG |
42 | int nrIter = Integer.parseInt(args[0]); |
43 | int waitTime = Integer.parseInt(args[1]); | |
9b21e6d5 DG |
44 | int fire_finest_tp = 0; |
45 | int fire_second_tp = 0; | |
46 | ||
47 | if (args.length > 2) { | |
48 | fire_finest_tp = Integer.parseInt(args[2]); | |
49 | } | |
50 | if (args.length > 3) { | |
51 | fire_second_tp = Integer.parseInt(args[3]); | |
52 | } | |
37175ce4 | 53 | |
0b7af945 MJ |
54 | /* Instantiate a LTTngLogHandler object, and attach it to our loggers */ |
55 | Handler lttngHandler = new LttngLogHandler(); | |
56 | lttng.addHandler(lttngHandler); | |
57 | lttng2.addHandler(lttngHandler); | |
58 | ||
88f54ca9 | 59 | lttng.setLevel(Level.FINEST); |
37175ce4 DG |
60 | |
61 | for (int iter = 0; iter < nrIter; iter++) { | |
62 | lttng.info("JUL tp fired!"); | |
9b21e6d5 | 63 | if (fire_finest_tp == 1) { |
88f54ca9 DG |
64 | /* Third arg, trigger finest TP. */ |
65 | lttng.finest("JUL FINEST tp fired"); | |
66 | } | |
37175ce4 DG |
67 | Thread.sleep(waitTime); |
68 | } | |
69 | ||
9b21e6d5 DG |
70 | if (fire_second_tp == 1) { |
71 | lttng2.info("JUL second logger fired"); | |
72 | } | |
73 | ||
0b7af945 MJ |
74 | /* |
75 | * Do not forget to close() all handlers so that the agent can shutdown | |
76 | * and the session daemon socket gets cleaned up explicitly. | |
77 | */ | |
78 | lttngHandler.close(); | |
37175ce4 DG |
79 | } |
80 | } |