Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "E4/EAS/Logging and Tracing"

< E4‎ | EAS
(e4 (Java))
m
Line 4: Line 4:
  
 
==Eclipse 3.x API==
 
==Eclipse 3.x API==
'''Logging:'''
+
===Logging===
 
*org.osgi.service.log.LogService
 
*org.osgi.service.log.LogService
 
*org.eclipse.core.runtime.ILog
 
*org.eclipse.core.runtime.ILog
  
'''Tracing:'''
+
====Retrieving LogService in 3.x====
*org.eclipse.core.runtime.Platform.getDebugOption(String)
+
 
+
===Retrieving LogService in 3.x===
+
 
A developer can retrieve the OSGi LogService via a ServiceTracker.
 
A developer can retrieve the OSGi LogService via a ServiceTracker.
  
Line 21: Line 18:
 
</source>
 
</source>
  
===Retrieving ILog===
+
====Retrieving ILog====
 
The org.eclipse.core.runtime.Platform class defines a static getLog(Bundle) method for retrieving an ILog.
 
The org.eclipse.core.runtime.Platform class defines a static getLog(Bundle) method for retrieving an ILog.
  
Line 37: Line 34:
 
}
 
}
 
</source>
 
</source>
 +
 +
===Tracing===
 +
*org.eclipse.core.runtime.Platform.getDebugOption(String)
  
 
==e4 (Java)==
 
==e4 (Java)==
'''Logging:'''
+
===Logging===
 
*org.eclipse.e4.core.services.Logger
 
*org.eclipse.e4.core.services.Logger
  
===Retrieving LogService in e4 (Java)===
+
====Retrieving LogService in e4 (Java)====
 
A developer can retrieve the OSGi LogService via a ServiceTracker as described [[#Retrieving LogService in 3.x|above]] or they can query their Eclipse context for it.
 
A developer can retrieve the OSGi LogService via a ServiceTracker as described [[#Retrieving LogService in 3.x|above]] or they can query their Eclipse context for it.
  
Line 52: Line 52:
  
 
'''Questions:'''
 
'''Questions:'''
* How does logging relate to status handling Should the code above know that it needs a logger or should it be relying on some execution context to help determine how visible the status should be?
+
* How does logging relate to [[E4/EAS/Status Handling|status handling]]? Should the code above know that it needs a logger or should it be relying on some execution context to help determine how visible the status should be?

Revision as of 12:11, 30 October 2009

Components are going to want a way to send information into a log somewhere. This needs to be pluggable so that they can contain and dictate where this information should go and how it should be logged. Ideally, the default output of what e4 applications produce should be consumable by the 'Error Log' view from Eclipse 3.x. It should also be possible for applications to enable tracing.

This service is related to status handling.

Eclipse 3.x API

Logging

  • org.osgi.service.log.LogService
  • org.eclipse.core.runtime.ILog

Retrieving LogService in 3.x

A developer can retrieve the OSGi LogService via a ServiceTracker.

private LogService getLogService() {
  fLogServiceTracker = new ServiceTracker(fBundleContext, LogService.class.getName(), null);
  return (LogService) fLogServiceTracker.getService();
}

Retrieving ILog

The org.eclipse.core.runtime.Platform class defines a static getLog(Bundle) method for retrieving an ILog.

Any subclass of org.eclipse.core.runtime.Plugin can also retrieve an ILog via the public getLog() method.

public class MyPlugin extends Plugin {
  public void start(BundleContext context) throws Exception {
    getLog().log(new Status(IStatus.OK, "org.eclipse.e4.core", "Starting org.eclipse.e4.core bundle...");
  }
 
  public void stop(BundleContext context) throws Exception {
    getLog().log(new Status(IStatus.OK, "org.eclipse.e4.core", "Stopping org.eclipse.e4.core bundle...");
  }
}

Tracing

  • org.eclipse.core.runtime.Platform.getDebugOption(String)

e4 (Java)

Logging

  • org.eclipse.e4.core.services.Logger

Retrieving LogService in e4 (Java)

A developer can retrieve the OSGi LogService via a ServiceTracker as described above or they can query their Eclipse context for it.

private LogService getLogService() {
  return (LogService) fEclipseContext.get(LogService.class.getName());
}

Questions:

  • How does logging relate to status handling? Should the code above know that it needs a logger or should it be relying on some execution context to help determine how visible the status should be?

Back to the top