2 * Copyright (C) 2015 - Michael Jeanson <mjeanson@efficios.com>
3 * Copyright (C) 2013 - David Goulet <dgoulet@efficios.com>
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.
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
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.
19 import java
.io
.IOException
;
20 import java
.lang
.Integer
;
21 import java
.util
.logging
.Handler
;
22 import java
.util
.logging
.Logger
;
23 import java
.util
.logging
.Level
;
25 import org
.lttng
.ust
.agent
.jul
.LttngLogHandler
;
27 public class JTestLTTng
{
33 * Command-line arguments
35 * @throws InterruptedException
37 public static void main(String args
[]) throws IOException
, InterruptedException
{
39 Logger lttng
= Logger
.getLogger("JTestLTTng");
40 Logger lttng2
= Logger
.getLogger("JTestLTTng2");
42 int nrIter
= Integer
.parseInt(args
[0]);
43 int waitTime
= Integer
.parseInt(args
[1]);
44 int fire_finest_tp
= 0;
45 int fire_second_tp
= 0;
47 if (args
.length
> 2) {
48 fire_finest_tp
= Integer
.parseInt(args
[2]);
50 if (args
.length
> 3) {
51 fire_second_tp
= Integer
.parseInt(args
[3]);
54 /* Instantiate a LTTngLogHandler object, and attach it to our loggers */
55 Handler lttngHandler
= new LttngLogHandler();
56 lttng
.addHandler(lttngHandler
);
57 lttng2
.addHandler(lttngHandler
);
59 lttng
.setLevel(Level
.FINEST
);
61 for (int iter
= 0; iter
< nrIter
; iter
++) {
62 lttng
.info("JUL tp fired!");
63 if (fire_finest_tp
== 1) {
64 /* Third arg, trigger finest TP. */
65 lttng
.finest("JUL FINEST tp fired");
67 Thread
.sleep(waitTime
);
70 if (fire_second_tp
== 1) {
71 lttng2
.info("JUL second logger fired");
75 * Do not forget to close() all handlers so that the agent can shutdown
76 * and the session daemon socket gets cleaned up explicitly.
This page took 0.03885 seconds and 4 git commands to generate.