Friday, June 13, 2008

Working with Multiple LogServices

The fact that there can be multiple registered services of a particular type can sometimes be problematic. Consider the LogService and it's cousin the LogReaderService. When there are multiple registered LogService and LogReaderService pairs it can be tricky for an application to be able to present a single view of the application's logged messages.

It is this reason that SAT now has a LogReaderAggregatorService. As its name implies, it aggregates each registered LogReaderService and presents a single service API with which to work with the application's entire log. The LogReaderAggregatorService is straight forward:
public interface LogReaderAggregatorService extends LogReaderService {
public Enumeration/*<LogEntry>*/ getLogInOrder();
public boolean isLoggingToConsole();
public void setLogToConsole(boolean logToConsole);
Since the interface extends the OSGi-defined LogReaderService you can use the API you're familiar with, such as getLog(), but of course what you'll get back is an Enumeration of every LogEvent for every registered LogReaderService, in reverse chronological order.

The LogReaderAggregatorService interfaces adds the method getLogInOrder() for accessing every logged message in chronological order, and a couple of methods for controlling whether logged messages will be echoed to the console.

While the LogReaderAggregatorService interface is part of the required bundle org.eclipse.soda.sat.core, the implementation lives in the optional bundle org.eclipse.soda.sat.core.log.


Ana said...

Hi Simon,

I am a beginner in Equinox. I am trying to work with the packet org.eclipse.soda.sat.core. However I cannot find it. I have been trying to find it online and with CVS, but I did not succeed. I would really appreciate your help.

Thanks in advance.

Simon Archer said...

Hi Ana,

You can find a selection of downloads on the right side of the blog under "SAT Downloads". The latest version for Eclipse/Equinox 3.5 is here.

Don't hesitate to ask if you have further questions. Good luck.

Ana said...

Thank you very much!
I am doing a PhD in Copenhage at DTU and I am goign to have to work with Equinox. I hope I won't need your help but that I think that is unlikely. Again, thanks for the help.

Simon Archer said...

SAT is certainly a great place to start using Equinox and OSGi.

Since SAT was created the OSGi specification and Equinox have evolved considerably. You should consider reading the following OSGi and Equinox book (of which I am one of the 3 authors), which is available online now, and will be available in hard-copy in March 2010.

You can email me too with questions about SAT, the book, or OSGi/Equinox. Good luck.

Planet Eclipse

Jazz Community News