tuwien.auto.calimero.log
Class LogManager

java.lang.Object
  extended by tuwien.auto.calimero.log.LogManager

public final class LogManager
extends java.lang.Object

Global Manager for LogServices and LogWriters.

There is only one instance of this manager in the library, obtained with getManager().
A log service can be queried and removed. A log writer can be added (i.e. registered) and removed, either to a particular log service or as a global log writer. A global log writer will receive all logging output from all registered log services.

See Also:
LogWriter, LogService

Method Summary
 boolean addWriter(java.lang.String logService, LogWriter writer)
          Adds a log writer, either global or to a particular log service.
 LogWriter[] getAllGlobalWriter()
          Returns all registered global log writer.
 java.lang.String[] getAllLogServices()
          Returns the names of all registered log services.
 LogService getLogService(java.lang.String name)
          Queries for a log service with the specified name.
static LogManager getManager()
          Returns the only instance of the log manager.
 boolean hasLogService(java.lang.String name)
          Checks whether a log service with name exists in the manager.
 void removeLogService(java.lang.String name)
          Removes a log service from the manager.
 void removeWriter(java.lang.String logService, LogWriter writer)
          Removes a log writer, either global or from a particular logService.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

addWriter

public boolean addWriter(java.lang.String logService,
                         LogWriter writer)
Adds a log writer, either global or to a particular log service.

Note that the writer is added to the log service(s) regardless if it was already added before.
If the writer is added global, it will receive logging information from all log services that are already registered or will be registered in the future.

Parameters:
logService - name of a log service; to add the writer global, use an empty string or null
writer - log writer to add
Returns:
true if the writer was added successfully,
false a specified log service name was not found
See Also:
LogService.addWriter(LogWriter)

getAllGlobalWriter

public LogWriter[] getAllGlobalWriter()
Returns all registered global log writer.

Global are all log writers which were not registered at a particular log service.

Returns:
array with global log writers

getAllLogServices

public java.lang.String[] getAllLogServices()
Returns the names of all registered log services.

Returns:
array of type String with log service names

getLogService

public LogService getLogService(java.lang.String name)
Queries for a log service with the specified name.

If the log service with this name already exists in the manager, it will be returned, otherwise a new log service with this name will be created and added to the log services listed in the manager.

Parameters:
name - name of log service, the empty string is not allowed
Returns:
the LogService object

getManager

public static LogManager getManager()
Returns the only instance of the log manager.

Returns:
the log manager object

hasLogService

public boolean hasLogService(java.lang.String name)
Checks whether a log service with name exists in the manager.

A log service is only listed in the manager, if it was initially queried using getLogService(String).

Parameters:
name - name of log service
Returns:
true if log service exists, false otherwise

removeLogService

public void removeLogService(java.lang.String name)
Removes a log service from the manager.

If no log service with the specified name is found, no action is performed.

Parameters:
name - name of log service

removeWriter

public void removeWriter(java.lang.String logService,
                         LogWriter writer)
Removes a log writer, either global or from a particular logService.

Note that for a writer to be removed global, it had to be added global before.

Parameters:
logService - name of the log service of which the writer will be removed; to remove the writer global, use an empty string or null
writer - log writer to remove
See Also:
LogService.removeWriter(LogWriter)