]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/internal/Policy.java
ad9f6468c2309b2b9b422d95deaa424ef67e1dad
[simantics/platform.git] / bundles / org.simantics.structural.synchronization.client / src / org / simantics / structural / synchronization / internal / Policy.java
1 package org.simantics.structural.synchronization.internal;
2
3 import org.eclipse.core.runtime.ILog;
4 import org.eclipse.core.runtime.IStatus;
5 import org.eclipse.core.runtime.Platform;
6 import org.eclipse.core.runtime.Status;
7 import org.osgi.framework.Bundle;
8
9 /**
10  * @author Tuukka Lehtonen
11  */
12 public final class Policy {
13
14         public static final String PLUGIN_ID = "org.simantics.structural.synchronization";
15
16         //public static boolean TRACE_EVENTS = false;
17
18         static {
19                 //String sTrue = Boolean.TRUE.toString();
20                 //DEBUG_... = sTrue.equalsIgnoreCase(Platform.getDebugOption(PLUGIN_ID + "/debug/synchronization/...")); //$NON-NLS-1$
21         }
22
23         public static ILog getLog() {
24                 Bundle b = Platform.getBundle(PLUGIN_ID);
25                 if (b != null)
26                         return Platform.getLog(b);
27                 throw new IllegalStateException("bundle " + PLUGIN_ID + " not resolved");
28         }
29
30         public static void log(IStatus status) {
31                 getLog().log(status);
32         }
33
34         public static void log(int severity, String message, Throwable t) {
35                 getLog().log(new Status(severity, PLUGIN_ID, message, t));
36         }
37
38         public static void logError(String message, Throwable t) {
39                 log(IStatus.ERROR, message, t);
40         }
41
42         public static void logError(Throwable t) {
43                 logError(t.getMessage(), t);
44         }
45
46         public static void logWarning(String message, Throwable t) {
47                 log(IStatus.WARNING, message, t);
48         }
49
50         public static void logWarning(Throwable t) {
51                 logWarning(t.getMessage(), t);
52         }
53
54 }