tmf: Avoid HistoryTree to expose its internal HT_IO node.
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / internal / tmf / core / Activator.java
1 /*******************************************************************************
2 * Copyright (c) 2009, 2013 Ericsson
3 *
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
8 *
9 * Contributors:
10 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.linuxtools.internal.tmf.core;
14
15 import org.eclipse.core.runtime.IStatus;
16 import org.eclipse.core.runtime.Plugin;
17 import org.eclipse.core.runtime.Status;
18 import org.eclipse.linuxtools.tmf.core.trace.TmfTraceManager;
19 import org.osgi.framework.BundleContext;
20
21 /**
22 * The activator class controls the plug-in life cycle. No more than one such
23 * plug-in can exist at any time.
24 * <p>
25 * It also provides the plug-in's general logging facility and manages the
26 * internal tracer.
27 */
28 public class Activator extends Plugin {
29
30 // ------------------------------------------------------------------------
31 // Attributes
32 // ------------------------------------------------------------------------
33
34 /**
35 * The plug-in ID
36 */
37 public static final String PLUGIN_ID = "org.eclipse.linuxtools.tmf.core"; //$NON-NLS-1$
38
39 /**
40 * The shared instance
41 */
42 private static Activator fPlugin;
43
44 // ------------------------------------------------------------------------
45 // Constructors
46 // ------------------------------------------------------------------------
47
48 /**
49 * Constructor
50 */
51 public Activator() {
52 setDefault(this);
53 }
54
55 // ------------------------------------------------------------------------
56 // Accessors
57 // ------------------------------------------------------------------------
58
59 /**
60 * Returns the TMF Core plug-in instance.
61 *
62 * @return the TMF Core plug-in instance.
63 */
64 public static Activator getDefault() {
65 return fPlugin;
66 }
67
68 // Sets plug-in instance
69 private static void setDefault(Activator plugin) {
70 fPlugin = plugin;
71 }
72
73 // ------------------------------------------------------------------------
74 // Plugin
75 // ------------------------------------------------------------------------
76
77 @Override
78 public void start(BundleContext context) throws Exception {
79 super.start(context);
80 setDefault(this);
81 TmfCoreTracer.init();
82 /* Initialize the trace manager */
83 TmfTraceManager.getInstance();
84 }
85
86 @Override
87 public void stop(BundleContext context) throws Exception {
88 TmfCoreTracer.stop();
89 setDefault(null);
90 super.stop(context);
91 }
92
93
94 // ------------------------------------------------------------------------
95 // Log an IStatus
96 // ------------------------------------------------------------------------
97
98 /**
99 * Log an IStatus object directly
100 *
101 * @param status
102 * The status to log
103 */
104 public static void log(IStatus status) {
105 fPlugin.getLog().log(status);
106 }
107
108 // ------------------------------------------------------------------------
109 // Log INFO
110 // ------------------------------------------------------------------------
111
112 /**
113 * Logs a message with severity INFO in the runtime log of the plug-in.
114 *
115 * @param message
116 * A message to log
117 */
118 public static void logInfo(String message) {
119 fPlugin.getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
120 }
121
122 /**
123 * Logs a message and exception with severity INFO in the runtime log of the
124 * plug-in.
125 *
126 * @param message
127 * A message to log
128 * @param exception
129 * The corresponding exception
130 */
131 public static void logInfo(String message, Throwable exception) {
132 fPlugin.getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message, exception));
133 }
134
135 // ------------------------------------------------------------------------
136 // Log WARNING
137 // ------------------------------------------------------------------------
138
139 /**
140 * Logs a message and exception with severity WARNING in the runtime log of
141 * the plug-in.
142 *
143 * @param message
144 * A message to log
145 */
146 public static void logWarning(String message) {
147 fPlugin.getLog().log(new Status(IStatus.WARNING, PLUGIN_ID, message));
148 }
149
150 /**
151 * Logs a message and exception with severity WARNING in the runtime log of
152 * the plug-in.
153 *
154 * @param message
155 * A message to log
156 * @param exception
157 * The corresponding exception
158 */
159 public static void logWarning(String message, Throwable exception) {
160 fPlugin.getLog().log(new Status(IStatus.WARNING, PLUGIN_ID, message, exception));
161 }
162
163 // ------------------------------------------------------------------------
164 // Log ERROR
165 // ------------------------------------------------------------------------
166
167 /**
168 * Logs a message and exception with severity ERROR in the runtime log of
169 * the plug-in.
170 *
171 * @param message
172 * A message to log
173 */
174 public static void logError(String message) {
175 fPlugin.getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message));
176 }
177
178 /**
179 * Logs a message and exception with severity ERROR in the runtime log of
180 * the plug-in.
181 *
182 * @param message
183 * A message to log
184 * @param exception
185 * The corresponding exception
186 */
187 public static void logError(String message, Throwable exception) {
188 fPlugin.getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message, exception));
189 }
190 }
This page took 0.034375 seconds and 5 git commands to generate.