com.ryanm.logging
Class LoggingManager

java.lang.Object
  extended by com.ryanm.logging.LoggingManager

public class LoggingManager
extends java.lang.Object

The main logging class.

Author:
ryanm

Constructor Summary
LoggingManager()
           
 
Method Summary
static void addAssociationListener(AssociationListener listener)
          Adds an AssociationListener to the LoggingManager.
static void addSinkRegistrationListener(SinkRegistrationListener listener)
          Adds an SinkRegistrationListener to the LoggingManager.
static void addSourceRegistrationListener(SourceRegistrationListener listener)
          Adds an SourceRegistrationListener to the LoggingManager.
static void associate(java.lang.String source, LogSink sink)
          Associates a sink to a source.
static void deregister(LogSink sink)
          Deregisters a sink.
static void deregister(java.lang.String source)
          Removes a source from the registration list.
static void disassociate(java.lang.String source, LogSink sink)
          Removes an association between a source and sink.
static Configurator getConfigurator()
          Gets a configurator that can control the logging system
static java.util.List<LogSink> getRegisteredSinks()
          Returns a list of registered sinks.
static java.util.List<java.lang.String> getRegisteredSources()
          Returns a list of all registered sources.
static java.util.List<java.lang.String> getRegisteredSources(LogSink sink)
          Generates a list of all the registered sources that a particular sink is associated with
static void log(java.lang.String source, java.lang.String message)
          Logs a message.
static void log(java.lang.String source, java.lang.String message, java.lang.Object param)
          Logs a message.
static void register(LogSink sink)
          Registers a sink.
static void register(java.lang.String source)
          Registers a source.
static void removeAssociationListener(AssociationListener listener)
          Removes an AssociationListener from the LoggingManager.
static void removeSinkRegistrationListener(SinkRegistrationListener listener)
          Removes an SinkRegistrationListener from the LoggingManager.
static void removeSourceRegistrationListener(SourceRegistrationListener listener)
          Removes an SourceRegistrationListener from the LoggingManager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LoggingManager

public LoggingManager()
Method Detail

associate

public static void associate(java.lang.String source,
                             LogSink sink)
Associates a sink to a source. Messages logged with the source will be processed by the supplied sink. If such an association already exists, then no change is made.

Parameters:
source - The source of messages
sink - The sink that should process messages from the source

disassociate

public static void disassociate(java.lang.String source,
                                LogSink sink)
Removes an association between a source and sink. If no such association existed, then no change is made

Parameters:
source - The source of messages
sink - The sink that should no longer process messages from that source

log

public static void log(java.lang.String source,
                       java.lang.String message)
Logs a message. The message will be conveyed to all LogSinks that are associated with the specified source

Parameters:
source - The source of the message
message - The body of the message

log

public static void log(java.lang.String source,
                       java.lang.String message,
                       java.lang.Object param)
Logs a message. The message will be conveyed to all LogSinks that are associated with the specified source

Parameters:
source - The source of the message
message - The message body
param - Parameters to the message

getRegisteredSources

public static java.util.List<java.lang.String> getRegisteredSources()
Returns a list of all registered sources. This would be useful if you want to construct a gui to control logging.

Returns:
A list of source String identifiers.

getRegisteredSources

public static java.util.List<java.lang.String> getRegisteredSources(LogSink sink)
Generates a list of all the registered sources that a particular sink is associated with

Parameters:
sink - The sink to query
Returns:
A List of all registered source identifier Strings that are associated with the sink

getRegisteredSinks

public static java.util.List<LogSink> getRegisteredSinks()
Returns a list of registered sinks. This would be useful if you want to construct a gui to control logging.

Returns:
A list of registered sinks.

register

public static void register(java.lang.String source)
Registers a source. This means it will appear in the output of getRegisteredSources(). Duplicate and null registrations are ignored. Source names must not contain the ":" character

Parameters:
source - The source identifier to register.

deregister

public static void deregister(java.lang.String source)
Removes a source from the registration list. It will no longer appear in the output of getRegisteredSources(). Note that it will function as normal.

Parameters:
source - The source to deregister

register

public static void register(LogSink sink)
Registers a sink. This means it will appear in the output of getRegisteredSinks(). Duplicate and null registrations are ignored.

Parameters:
sink - The sink to register.

deregister

public static void deregister(LogSink sink)
Deregisters a sink. It will no longer appear in the output of getRegisteredSinks(). Note that it will function as normal.

Parameters:
sink - The sink to deregister.

addAssociationListener

public static void addAssociationListener(AssociationListener listener)
Adds an AssociationListener to the LoggingManager. The listener will be notified of any changes to the status of the LoggingManager

Parameters:
listener - The listener to register.

removeAssociationListener

public static void removeAssociationListener(AssociationListener listener)
Removes an AssociationListener from the LoggingManager. The listener will no longer be notified of any changes to the status of the LoggingManager.

Parameters:
listener - The listener to deregister.

addSinkRegistrationListener

public static void addSinkRegistrationListener(SinkRegistrationListener listener)
Adds an SinkRegistrationListener to the LoggingManager. The listener will be notified of any changes to the status of the LoggingManager

Parameters:
listener - The listener to register.

removeSinkRegistrationListener

public static void removeSinkRegistrationListener(SinkRegistrationListener listener)
Removes an SinkRegistrationListener from the LoggingManager. The listener will no longer be notified of any changes to the status of the LoggingManager.

Parameters:
listener - The listener to deregister.

addSourceRegistrationListener

public static void addSourceRegistrationListener(SourceRegistrationListener listener)
Adds an SourceRegistrationListener to the LoggingManager. The listener will be notified of any changes to the status of the LoggingManager

Parameters:
listener - The listener to register.

removeSourceRegistrationListener

public static void removeSourceRegistrationListener(SourceRegistrationListener listener)
Removes an SourceRegistrationListener from the LoggingManager. The listener will no longer be notified of any changes to the status of the LoggingManager.

Parameters:
listener - The listener to deregister.

getConfigurator

public static Configurator getConfigurator()
Gets a configurator that can control the logging system

Returns:
A configurator