@@ -35,7 +35,7 @@ public static Activator getDefault() {
35
35
public void start (BundleContext context ) throws Exception {
36
36
super .start (context );
37
37
plugin = this ;
38
- log ("Startup " );
38
+ log ("Starting... " );
39
39
}
40
40
41
41
@ Override
@@ -44,15 +44,31 @@ public void stop(BundleContext context) throws Exception {
44
44
super .stop (context );
45
45
}
46
46
47
+ // ------------------------------------------
48
+
49
+ public static void log (Throwable e ) {
50
+ plugin .getLog ().log (new Status (IStatus .ERROR , PLUGIN_ID , e .getMessage ()));
51
+ }
52
+
47
53
public static void log (String fmt , Object ... args ) {
48
- plugin .getLog ().log (new Status (IStatus .INFO , PLUGIN_ID , PREFIX + String .format (fmt , args )));
54
+ String msg = print (PREFIX + String .format (fmt , args ));
55
+ plugin .getLog ().log (new Status (IStatus .INFO , PLUGIN_ID , msg ));
49
56
}
50
57
51
58
public static void log (MsgBuilder mb ) {
52
- plugin .getLog ().log (new Status (IStatus .INFO , PLUGIN_ID , PREFIX + mb .toString ()));
59
+ String msg = print (PREFIX + mb .toString ());
60
+ plugin .getLog ().log (new Status (IStatus .INFO , PLUGIN_ID , msg ));
53
61
}
54
62
55
- public static void log (Throwable e ) {
56
- plugin .getLog ().log (new Status (IStatus .ERROR , PLUGIN_ID , e .getMessage ()));
63
+ private static String print (String msg ) {
64
+ StackTraceElement caller = Thread .currentThread ().getStackTrace ()[3 ];
65
+ return info (caller .getClassName (), caller .getLineNumber (), msg );
66
+ }
67
+
68
+ private static String info (String clsname , int line , String msg ) {
69
+ if (clsname .startsWith (PLUGIN_ID )) {
70
+ clsname = clsname .substring (PLUGIN_ID .length () + 1 );
71
+ }
72
+ return String .format ("%s:%s \t %s" , clsname , line , msg );
57
73
}
58
74
}
0 commit comments