2 * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir <alexmonthy@efficios.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program 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
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 package org
.lttng
.tools
;
21 import java
.util
.List
;
24 * Java representation of a LTTng tracing session.
26 * @author Alexandre Montplaisir
28 public interface ILttngSession
extends AutoCloseable
{
31 * Tracing domains as they are defined by lttng-tools
34 /** The JUL (java.util.logging) domain */
35 JUL("--jul", ">=", Integer
.MIN_VALUE
), /** The log4j (org.apache.log4j) domain */
36 LOG4J("--log4j", ">=", Integer
.MIN_VALUE
),
37 LOG4J2("--log4j2", "<=", Integer
.MAX_VALUE
);
39 private final String flag
;
40 private final String rangeOperator
;
41 private final int levelAllValue
;
43 private Domain(String flag
, String rangeOperator
, int levelAllValue
) {
45 this.rangeOperator
= rangeOperator
;
46 this.levelAllValue
= levelAllValue
;
50 * @return The corresponding command-line flag to pass to options like
51 * "lttng enable-event"
53 public String
flag() {
57 public String
rangeOperator() {
61 public int levelAllValue() {
66 // ------------------------------------------------------------------------
68 // ------------------------------------------------------------------------
71 * Create a new LTTng tracing session using the default backend.
74 * The name of the session to use. It can be null, in which case
75 * we will provide a unique random name.
77 * The tracing domain of this session
78 * @return The new session object
80 static ILttngSession
createSession(String sessionName
, Domain domain
) {
81 return createCommandLineSession(sessionName
, domain
);
85 * Create a new LTTng tracing session, which will use the command-line
89 * The name of the session to use. It can be null, in which case
90 * we will provide a unique random name.
92 * The tracing domain of this session
93 * @return The new session object
95 static ILttngSession
createCommandLineSession(String sessionName
, Domain domain
) {
96 return new LttngCommandLineSession(sessionName
, domain
);
99 // ------------------------------------------------------------------------
101 // ------------------------------------------------------------------------
104 * Should be used to destroy the LTTng session.
109 // ------------------------------------------------------------------------
110 // Session management
111 // ------------------------------------------------------------------------
114 * Enable an individual event, specifying a loglevel and filter string.
117 * The name of the event to enable
119 * The loglevel, will be passed as-is to lttng. May be null to
121 * @param loglevelOnly
122 * True to use this log level only (--loglevel-only), or false to
123 * include all more severe levels (--loglevel). Ignored if
124 * "loglevel" is null.
126 * The filter string, may be null to not specify one.
127 * @return If the command executed successfully (return code = 0)
129 boolean enableEvent(String eventName
, String loglevel
, boolean loglevelOnly
, String filter
);
132 * Enable individual event(s) with no loglevel/filter specified.
134 * @param enabledEvents
135 * The list of events to enable. Should not be null or empty
136 * @return If the command executed successfully (return code = 0).
138 boolean enableEvents(String
... enabledEvents
);
141 * Enable all events in the session (as with "enable-event -a").
143 * @return If the command executed successfully (return code = 0).
145 boolean enableAllEvents();
148 * Send a disable-event command. Used to disable event(s) that were previously
151 * @param disabledEvents
152 * The list of disabled events. Should not be null or empty
153 * @return If the command executed successfully (return code = 0).
155 boolean disableEvents(String
... disabledEvents
);
158 * Disable all events currently enabled in the session
159 * ("lttng disable-event -a").
161 * @return If the command executed successfully (return code = 0)
163 boolean disableAllEvents();
166 * Get a list of events currently available (exposed by applications) in the
169 * @return The list of available events
171 List
<String
> listEvents();
174 * Enable an application context with the provided retriever/context names.
176 * There is currently no direct command to remove an existing context, the
177 * session has to be destroyed and re-created to do so.
179 * @param retrieverName
180 * The name of the retriever (or "namespace" of the context)
182 * The name of the context
183 * @return If the command executed successfully (return code = 0)
185 boolean enableAppContext(String retrieverName
, String contextName
);
190 * @return If the command executed successfully (return code = 0).
195 * Stop the tracing session
197 * @return If the command executed successfully (return code = 0).
202 * Issue a "lttng view" command on the session, and returns its output. This
203 * effectively returns the current content of the trace in text form.
205 * @return The output of Babeltrace on the session's current trace
This page took 0.038728 seconds and 5 git commands to generate.