The Meta-Environment API

toolbus.logging
Class LoggerFactory

java.lang.Object
  extended by toolbus.logging.LoggerFactory

public class LoggerFactory
extends java.lang.Object

Factory for creating a logger. Follows singleton design pattern.

Author:
Arnold Lankamp

Nested Class Summary
private static class LoggerFactory.LoggerKeeper
          Instance keeper; for ensuring thread-safe, lazy intialization of the logger.
 
Field Summary
private static java.lang.String filter
           
private static int nrOfRegisteredNames
           
private static java.util.Set<java.lang.String> registeredNames
           
private static java.util.Set<java.lang.String> registeredTypes
           
 
Constructor Summary
private LoggerFactory()
          Default constructor.
 
Method Summary
static void deregisterName(java.lang.String name)
          Deregisters the given string as a name, so the messages that are associated with it will no longer be logged.
static void deregisterType(java.lang.String type)
          Deregisters the given string as log type identifier, so the messages that are associated with it will no longer be logged.
static ILogger getLogger()
          Returns a reference to the instantiated logger.
static void log(java.lang.String message, int loglevel, java.lang.String type)
          Convenience method for logging.
static void log(java.lang.String processName, java.lang.String message, java.lang.String type)
          Convenience method for debugging.
static void log(java.lang.String message, java.lang.Throwable throwable, int loglevel, java.lang.String type)
          Convenience method for logging.
static void registerName(java.lang.String name)
          Registers the given string as a name.
static void registerType(java.lang.String type)
          Registers the given string as a log type identifier.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

registeredTypes

private static final java.util.Set<java.lang.String> registeredTypes

registeredNames

private static final java.util.Set<java.lang.String> registeredNames

nrOfRegisteredNames

private static int nrOfRegisteredNames

filter

private static java.lang.String filter
Constructor Detail

LoggerFactory

private LoggerFactory()
Default constructor. Private to prevent instantiation.

Method Detail

registerType

public static void registerType(java.lang.String type)
Registers the given string as a log type identifier. All registered log types will be logged. All messages with log types that aren't registered will be ignored.

Parameters:
type - The log type identifier.

deregisterType

public static void deregisterType(java.lang.String type)
Deregisters the given string as log type identifier, so the messages that are associated with it will no longer be logged.

Parameters:
type - The log type identifier.

registerName

public static void registerName(java.lang.String name)
Registers the given string as a name. Only messages containing name will be logged.

Parameters:
name - The name of interest.

deregisterName

public static void deregisterName(java.lang.String name)
Deregisters the given string as a name, so the messages that are associated with it will no longer be logged.

Parameters:
name - The name of interest.

log

public static void log(java.lang.String processName,
                       java.lang.String message,
                       java.lang.String type)
Convenience method for debugging.

Parameters:
processName - TODO
message - The message that needs to be logged.
type - The type of the message.

log

public static void log(java.lang.String message,
                       int loglevel,
                       java.lang.String type)
Convenience method for logging.

Parameters:
message - The message that needs to be logged.
loglevel - The log level of the message.

log

public static void log(java.lang.String message,
                       java.lang.Throwable throwable,
                       int loglevel,
                       java.lang.String type)
Convenience method for logging.

Parameters:
message - The message that needs to be logged.
throwable - The stacktrace associated with the message.
loglevel - The log level of the message.

getLogger

public static ILogger getLogger()
Returns a reference to the instantiated logger.

Returns:
A reference to the instantiated logger.

The Meta-Environment API