1 /**********************************************************************
2 * Copyright (c) 2012 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
12 package org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.preferences
;
14 import org
.eclipse
.jface
.preference
.IPreferenceStore
;
15 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.Activator
;
16 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.logging
.ControlCommandLogger
;
19 * <b><u>ControlPreference</u></b>
21 * Singleton class to access LTTng tracer control preferences.
24 public class ControlPreferences
{
26 // ------------------------------------------------------------------------
28 // ------------------------------------------------------------------------
29 public static final String TRACE_CONTROL_LOG_FILENAME
= "lttng_control.log"; //$NON-NLS-1$
32 public static final String TRACE_CONTROL_TRACING_GROUP_PREF
= "trace.control.tracing.group"; //$NON-NLS-1$
33 public static final String TRACE_CONTROL_LOG_COMMANDS_PREF
= "trace.control.log.commands"; //$NON-NLS-1$
34 public static final String TRACE_CONTROL_LOG_APPEND_PREF
= "trace.control.log.append"; //$NON-NLS-1$
35 public static final String TRACE_CONTROL_LOG_FILE_PATH_PREF
= "trace.control.log.path"; //$NON-NLS-1$
36 public static final String TRACE_CONTROL_VERBOSE_LEVEL_PREF
= "trace.control.verbose.level"; //$NON-NLS-1$
37 public static final String TRACE_CONTROL_VERBOSE_LEVEL_NONE
= "trace.control.verbose.level.none"; //$NON-NLS-1$
38 public static final String TRACE_CONTROL_VERBOSE_LEVEL_VERBOSE
= "trace.control.verbose.level.v"; //$NON-NLS-1$
39 public static final String TRACE_CONTROL_VERBOSE_LEVEL_V_VERBOSE
= "trace.control.verbose.level.vv"; //$NON-NLS-1$
40 public static final String TRACE_CONTROL_VERBOSE_LEVEL_V_V_VERBOSE
= "trace.control.verbose.level.vvv"; //$NON-NLS-1$
42 public static final String TRACE_CONTROL_DEFAULT_TRACING_GROUP
= "tracing"; //$NON-NLS-1$
43 public static final String TRACE_CONTROL_DEFAULT_LOG_PATH
= "${workspace_loc}/" + TRACE_CONTROL_LOG_FILENAME
; //$NON-NLS-1$
45 // ------------------------------------------------------------------------
47 // ------------------------------------------------------------------------
48 private static ControlPreferences fInstance
= null;
50 // ------------------------------------------------------------------------
52 // ------------------------------------------------------------------------
53 private ControlPreferences() {
56 // ------------------------------------------------------------------------
58 // ------------------------------------------------------------------------
59 public synchronized static ControlPreferences
getInstance() {
60 if (fInstance
== null) {
61 fInstance
= new ControlPreferences();
67 * @return the preference store
69 public IPreferenceStore
getPreferenceStore() {
70 return Activator
.getDefault().getPreferenceStore();
74 * @return true if tracing group is set to default
76 public boolean isDefaultTracingGroup() {
77 IPreferenceStore store
= getPreferenceStore();
78 return store
.getString(TRACE_CONTROL_TRACING_GROUP_PREF
).equals(store
.getDefaultString(TRACE_CONTROL_TRACING_GROUP_PREF
));
82 * @return value of tracing group preference
84 public String
getTracingGroup() {
85 return getPreferenceStore().getString(TRACE_CONTROL_TRACING_GROUP_PREF
);
89 * @return whether is logging is enabled
91 public boolean isLoggingEnabled() {
92 return getPreferenceStore().getBoolean(TRACE_CONTROL_LOG_COMMANDS_PREF
);
96 * @return whether an existing log file will appended or not
98 public boolean isAppend() {
99 return getPreferenceStore().getBoolean(ControlPreferences
.TRACE_CONTROL_LOG_APPEND_PREF
);
103 * @return verbose level preference
105 public String
getVerboseLevel() {
106 return getPreferenceStore().getString(TRACE_CONTROL_VERBOSE_LEVEL_PREF
);
109 // ------------------------------------------------------------------------
111 // ------------------------------------------------------------------------
113 * Initializes the control preferences (e.g. enable open log file)
116 if (getPreferenceStore().getBoolean(ControlPreferences
.TRACE_CONTROL_LOG_COMMANDS_PREF
)) {
117 ControlCommandLogger
.init(ControlPreferences
.TRACE_CONTROL_LOG_FILENAME
, isAppend());
122 * Disposes any resource (e.g. close log file).
124 public void dispose() {
125 ControlCommandLogger
.close();