1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 package net.sf.tm.plugin;
34
35 import org.eclipse.core.runtime.ILog;
36 import org.eclipse.core.runtime.IStatus;
37 import org.eclipse.core.runtime.Status;
38
39 /***
40 * A simple logger using the eclipse plugin login mechanism.
41 *
42 * @author Andreas Pataki
43 * @version $Id: Logger.java,v 1.1 2003/08/20 15:08:25 apataki Exp $
44 */
45 public final class Logger {
46
47 /***
48 * plugin log instance
49 */
50 private static ILog log;
51 /***
52 * value shows if debuggin is enabled
53 */
54 private static boolean debug;
55 /***
56 * ID of the plugin
57 */
58 private static String uniqueIdentifier;
59
60 /***
61 * Static initializer.
62 */
63 static {
64 log = ContextManagerPlugin.getDefault().getLog();
65 debug = ContextManagerPlugin.getDefault().isDebugging();
66 uniqueIdentifier =
67 ContextManagerPlugin
68 .getDefault()
69 .getDescriptor()
70 .getUniqueIdentifier();
71 }
72
73 /***
74 * hidden constructor
75 *
76 */
77 private Logger() {
78 }
79
80 /***
81 * Prints an error message to the Eclipse log.
82 *
83 * @param message error message
84 * @param exception catched exception
85 */
86 public static void error(String message, Throwable exception) {
87 log.log(
88 new Status(IStatus.ERROR, uniqueIdentifier, 0, message, exception));
89 }
90
91 /***
92 * Prints a debug statement to the Eclipse log.
93 *
94 * @param message error message
95 */
96 public static void debug(String message) {
97 if (debug) {
98 log.log(
99 new Status(IStatus.INFO, uniqueIdentifier, 0, message, null));
100
101 }
102 }
103
104 /***
105 * @return TRUE if tracing is enabled for the plugin
106 */
107 public static boolean isDebugEnabled() {
108 return debug;
109 }
110
111 }