3535 */
3636package com .salesforce .bazel .eclipse ;
3737
38- import java .io .File ;
39- import java .io .IOException ;
40- import java .net .URL ;
41-
42- import org .eclipse .core .resources .ResourcesPlugin ;
43- import org .eclipse .core .runtime .FileLocator ;
44- import org .eclipse .core .runtime .ILog ;
45- import org .eclipse .core .runtime .IPath ;
46- import org .eclipse .core .runtime .Path ;
47- import org .eclipse .core .runtime .Platform ;
48- import org .eclipse .core .runtime .Status ;
4938import org .osgi .framework .Bundle ;
50- import org .osgi .framework .FrameworkUtil ;
51- import org .slf4j .ILoggerFactory ;
52- import org .slf4j .LoggerFactory ;
53- import org .slf4j .helpers .MessageFormatter ;
5439
40+ import com .salesforce .bazel .eclipse .logging .BasicLoggerFacade ;
5541import com .salesforce .bazel .eclipse .logging .LoggerFacade ;
56- import com .salesforce .bazel .eclipse .logging .Slf4jLoggerFacade ;
57-
58- import ch .qos .logback .classic .LoggerContext ;
59- import ch .qos .logback .classic .joran .JoranConfigurator ;
60- import ch .qos .logback .core .joran .spi .JoranException ;
6142
6243/**
6344 * Add Eclipse Platform logging to WARN and ERROR log messages as well as slf4j logging api.
64- *
65- * @author Blaine Buxton
66- *
45+ * <p>
46+ * TODO we will revisit this logging feature later, see https://github.com/salesforce/bazel-eclipse/issues/10
6747 */
68- public class EclipseLoggerFacade extends Slf4jLoggerFacade {
69- private static final Bundle BUNDLE = FrameworkUtil .getBundle (EclipseLoggerFacade .class );
70- private static final ILog LOG = Platform .getLog (BUNDLE );
48+ public class EclipseLoggerFacade extends BasicLoggerFacade {
49+ // private static final Bundle BUNDLE = FrameworkUtil.getBundle(EclipseLoggerFacade.class);
50+ // private static final ILog LOG = Platform.getLog(BUNDLE);
7151
7252 /**
7353 * Install the facade as the singleton and configure logging system
@@ -77,8 +57,8 @@ public class EclipseLoggerFacade extends Slf4jLoggerFacade {
7757 */
7858 public static void install (Bundle bundle ) throws Exception {
7959 EclipseLoggerFacade instance = new EclipseLoggerFacade ();
80- LoggerFacade .setInstance (new EclipseLoggerFacade () );
81- instance .configureLogging (bundle );
60+ LoggerFacade .setInstance (instance );
61+ // instance.configureLogging(bundle);
8262 }
8363
8464 /**
@@ -89,22 +69,22 @@ private EclipseLoggerFacade() {}
8969 @ Override
9070 public void error (Class <?> from , String message , Object ... args ) {
9171 super .error (from , message , args );
92- String resolved = MessageFormatter .arrayFormat (message , args ).getMessage ();
93- LOG .log (new Status (Status .ERROR , BUNDLE .getSymbolicName (), resolved ));
72+ // String resolved = MessageFormatter.arrayFormat(message, args).getMessage();
73+ // LOG.log(new Status(Status.ERROR, BUNDLE.getSymbolicName(), resolved));
9474 }
9575
9676 @ Override
9777 public void error (Class <?> from , String message , Throwable exception , Object ... args ) {
9878 super .error (from , message , exception , args );
99- String resolved = MessageFormatter .arrayFormat (message , args ).getMessage ();
100- LOG .log (new Status (Status .ERROR , BUNDLE .getSymbolicName (), resolved , exception ));
79+ // String resolved = MessageFormatter.arrayFormat(message, args).getMessage();
80+ // LOG.log(new Status(Status.ERROR, BUNDLE.getSymbolicName(), resolved, exception));
10181 }
10282
10383 @ Override
10484 public void warn (Class <?> from , String message , Object ... args ) {
10585 super .warn (from , message , args );
106- String resolved = MessageFormatter .arrayFormat (message , args ).getMessage ();
107- LOG .log (new Status (Status .INFO , BUNDLE .getSymbolicName (), resolved ));
86+ // String resolved = MessageFormatter.arrayFormat(message, args).getMessage();
87+ // LOG.log(new Status(Status.INFO, BUNDLE.getSymbolicName(), resolved));
10888 }
10989
11090 /**
@@ -114,55 +94,55 @@ public void warn(Class<?> from, String message, Object... args) {
11494 * @throws JoranException
11595 * @throws IOException
11696 */
117- private void configureLogging (Bundle bundle ) throws JoranException , IOException {
97+ // private void configureLogging(Bundle bundle) throws JoranException, IOException {
11898 // capture the logger context, but guard against:
11999 // org.slf4j.helpers.NOPLoggerFactory cannot be cast to ch.qos.logback.classic.LoggerContext
120- ILoggerFactory iFactory = LoggerFactory .getILoggerFactory ();
121- if (iFactory instanceof LoggerContext ) {
122- LoggerContext context = (LoggerContext ) LoggerFactory .getILoggerFactory ();
123- JoranConfigurator jc = new JoranConfigurator ();
124- jc .setContext (context );
125- context .reset ();
126-
127- IPath pluginPath = ResourcesPlugin .getPlugin ().getStateLocation ();
128- String logFile = new File (pluginPath .toFile (), bundle .getSymbolicName ().replace ('.' , '_' ) + ".log" )
129- .getAbsolutePath ();
130- context .putProperty ("logFile" , logFile );
131- eclipseOnlyInfo ("Debug log file: {}" , logFile );
132-
133- URL logbackConfig = FileLocator .find (bundle , new Path ("logback.xml" ), null );
134- if (null == logbackConfig ) {
135- //not found log an event to the error log
136- error (getClass (), "logback.xml not found. All slf4j output to console" );
137- }
138- jc .doConfigure (logbackConfig );
139- } else {
140- // Logback was missing from the classpath when logging was initialized for some reason
141-
142- // check classloader to see if it is there now (if it is, there must be a load order issue?)
143- String isLoggerContextIsInClasspathStr =
144- "The class ch.qos.logback.classic.LoggerContext is not present in the classpath which means the plugin never imported it." ;
145- try {
146- Class .forName ("ch.qos.logback.classic.LoggerContext" );
147- isLoggerContextIsInClasspathStr =
148- "The class ch.qos.logback.classic.LoggerContext is NOW available in the classpath, which means there was a startup loading issue. The class wasn't there when logging was initialized." ;
149- } catch (Exception cnfe ) {}
150-
151- System .err .println (
152- "com.salesforce.bazel.eclipse.core: EclipseLoggerFacade could not configure file (INFO, DEBUG) logging. LoggerFactory is of type ["
153- + iFactory .getClass ()
154- + "] but needed [ch.qos.logback.classic.LoggerContext] to configure the file log. "
155- + isLoggerContextIsInClasspathStr + " See "
156- + "bazel-eclipse/docs/dev/logging.md for more details." );
157-
158- // set the activator convenience methods to log to sys err
159- BazelPluginActivator .logToSystemErr ();
160- }
161- }
162-
163- private void eclipseOnlyInfo (String message , Object ... args ) {
164- String resolved = MessageFormatter .arrayFormat (message , args ).getMessage ();
165- LOG .log (new Status (Status .INFO , BUNDLE .getSymbolicName (), resolved ));
166- }
100+ // ILoggerFactory iFactory = LoggerFactory.getILoggerFactory();
101+ // if (iFactory instanceof LoggerContext) {
102+ // LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
103+ // JoranConfigurator jc = new JoranConfigurator();
104+ // jc.setContext(context);
105+ // context.reset();
106+ //
107+ // IPath pluginPath = ResourcesPlugin.getPlugin().getStateLocation();
108+ // String logFile = new File(pluginPath.toFile(), bundle.getSymbolicName().replace('.', '_') + ".log")
109+ // .getAbsolutePath();
110+ // context.putProperty("logFile", logFile);
111+ // eclipseOnlyInfo("Debug log file: {}", logFile);
112+ //
113+ // URL logbackConfig = FileLocator.find(bundle, new Path("logback.xml"), null);
114+ // if (null == logbackConfig) {
115+ // //not found log an event to the error log
116+ // error(getClass(), "logback.xml not found. All slf4j output to console");
117+ // }
118+ // jc.doConfigure(logbackConfig);
119+ // } else {
120+ // // Logback was missing from the classpath when logging was initialized for some reason
121+ //
122+ // // check classloader to see if it is there now (if it is, there must be a load order issue?)
123+ // String isLoggerContextIsInClasspathStr =
124+ // "The class ch.qos.logback.classic.LoggerContext is not present in the classpath which means the plugin never imported it.";
125+ // try {
126+ // Class.forName("ch.qos.logback.classic.LoggerContext");
127+ // isLoggerContextIsInClasspathStr =
128+ // "The class ch.qos.logback.classic.LoggerContext is NOW available in the classpath, which means there was a startup loading issue. The class wasn't there when logging was initialized.";
129+ // } catch (Exception cnfe) {}
130+ //
131+ // System.err.println(
132+ // "com.salesforce.bazel.eclipse.core: EclipseLoggerFacade could not configure file (INFO, DEBUG) logging. LoggerFactory is of type ["
133+ // + iFactory.getClass()
134+ // + "] but needed [ch.qos.logback.classic.LoggerContext] to configure the file log. "
135+ // + isLoggerContextIsInClasspathStr + " See "
136+ // + "bazel-eclipse/docs/dev/logging.md for more details.");
137+ //
138+ // // set the activator convenience methods to log to sys err
139+ // BazelPluginActivator.logToSystemErr();
140+ // }
141+ // }
142+
143+ // private void eclipseOnlyInfo(String message, Object... args) {
144+ // String resolved = MessageFormatter.arrayFormat(message, args).getMessage();
145+ // LOG.log(new Status(Status.INFO, BUNDLE.getSymbolicName(), resolved));
146+ // }
167147
168148}
0 commit comments