org.openmdx.kernel.log.impl
Class AbstractLoggingMechanism

java.lang.Object
  extended by org.openmdx.kernel.log.impl.AbstractLoggingMechanism
All Implemented Interfaces:
ManageableMechanism
Direct Known Subclasses:
AbstractFileLoggingMechanism, PluggableLoggingMechanismProxy, SLF4JLoggingMechanism, SocketLoggingMechanism, StandardErrLoggingMechanism

public abstract class AbstractLoggingMechanism
extends Object
implements ManageableMechanism

AbstractLoggingMechanism is an abstract class which serves to define a hierarchy of different logging mechanisms. Subclasses of this class will implement the different mechanisms defined herein. The main responsibility of this class hierarchy is to offload the implementation work for differences in logging streams for different mechanisms. For example, the standard error stream is a very different implementation than a shared local output file.


Field Summary
static String OPEN_DATE_FORMAT
           
 
Constructor Summary
AbstractLoggingMechanism()
           
 
Method Summary
 boolean acceptsNotificationLogs()
          Checks if the mechanisms accepts notification logs.
 boolean acceptsPerformanceLogs()
          Checks if the mechanisms accepts performance logs.
 boolean acceptsStandardLogs()
          Checks if the mechanisms accepts standard logs.
 boolean acceptsStatisticLogs()
          Checks if the mechanisms accepts statistics logs.
protected  void close()
          This method closes the particular logging mechanism so that messages no longer get logged to the mechanism.
protected  LogFormatter createFormatter(String logName, LogProperties logProperties)
          Create a new log event formatter.
 LogEvent createNotificationEvent(Log log, String summary, String detail)
          Creates a notification log event.
 List getActiveEntities()
          Returns a list of all active (in use) log entities that are available by the file logging mechanisms controlled by this logger
protected  Date getDateOpend()
          The date this mechanism was openend.
protected  LogFormatter getFormatter()
          Returns the log event formatter.
protected  Vector getLoggers()
          The loggers that use this mechanism
 String getName()
          Return the name of the mechanism.
 List getReadableEntities()
          Returns a list of all readable log entities that are available by the file logging mechanisms controlled by this logger
 LogEntityReader getReader(LogEntity entity)
          Returns an entity reader for given log entity
 List getRemoveableEntities()
          Returns a list of all removeable log entities that are available by the file logging mechanisms controlled by this logger
protected  boolean isOpen()
          Returns true if the mechanism is open
protected  boolean isSharedLog()
          Mechanisms can be shared or unique.
protected abstract  void logEvent(Log log, LogEvent event)
          Logs a string to printStream, complete with a descriptive prefix so viewers of the log can interpret who logged which strings and how important they were.
protected  void notifyLogClosed(Log log)
          Log a message that a logger was closed on this mechanism
protected  void notifyLoggingLevelChange(Log log, int loggingLevel)
          Log a log level change
protected  void notifyLoggingPerformanceChange(Log log, boolean state)
          Log a performance change
protected  void notifyLoggingStatisticsChange(Log log, boolean state)
          Put out a nice message that a log changed its statistics state
protected  void notifyLogOpened(Log log, int loggingLevel)
          Log a message that a logger was openend on this mechanism
protected  void open(Log log)
          This method opens the particular logging mechanism so that messages can be output.
 void removeEntity(LogEntity entity)
          Remove a log entity
protected  void setFormatter(LogFormatter formatter)
          Sets a new log event formatter.
protected  void setNotification(boolean newMode)
          Sets a new notification mode
 String toString()
          Return a nice debug string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

OPEN_DATE_FORMAT

public static final String OPEN_DATE_FORMAT
See Also:
Constant Field Values
Constructor Detail

AbstractLoggingMechanism

public AbstractLoggingMechanism()
Method Detail

open

protected void open(Log log)
This method opens the particular logging mechanism so that messages can be output.


close

protected void close()
This method closes the particular logging mechanism so that messages no longer get logged to the mechanism.


notifyLogOpened

protected void notifyLogOpened(Log log,
                               int loggingLevel)
Log a message that a logger was openend on this mechanism

Parameters:
log - A logger
state - An initial log level

notifyLogClosed

protected void notifyLogClosed(Log log)
Log a message that a logger was closed on this mechanism

Parameters:
log - A logger

notifyLoggingLevelChange

protected void notifyLoggingLevelChange(Log log,
                                        int loggingLevel)
Log a log level change

Parameters:
log - A logger
state - A new log level

notifyLoggingPerformanceChange

protected void notifyLoggingPerformanceChange(Log log,
                                              boolean state)
Log a performance change

Parameters:
log - A logger
state - A new performance logging state

notifyLoggingStatisticsChange

protected void notifyLoggingStatisticsChange(Log log,
                                             boolean state)
Put out a nice message that a log changed its statistics state

Parameters:
log - A logger
state - A new state to be logged as notification

logEvent

protected abstract void logEvent(Log log,
                                 LogEvent event)
Logs a string to printStream, complete with a descriptive prefix so viewers of the log can interpret who logged which strings and how important they were.

Parameters:
log - A logger
event - A log event

isSharedLog

protected boolean isSharedLog()
Mechanisms can be shared or unique. Shared mechanisms require the log name to be in every log entry (so you can distinguish between the log entries). Unique mechanisms name themselves uniquely (for example, have the log name in their file name) so they do not have to put the name of the log in their log entry.

The default is shared (true).

Returns:
true if the mechanism is shared

setNotification

protected void setNotification(boolean newMode)
Sets a new notification mode

Parameters:
newMode - A new notification mode for the mechanism

isOpen

protected boolean isOpen()
Returns true if the mechanism is open

Returns:
true if the mechanism is open

getLoggers

protected Vector getLoggers()
The loggers that use this mechanism

Returns:
a vector of loggers

getDateOpend

protected Date getDateOpend()
The date this mechanism was openend.

Returns:
a Date or null if the mechanism is not open.

createFormatter

protected LogFormatter createFormatter(String logName,
                                       LogProperties logProperties)
Create a new log event formatter.

Parameters:
logName - the logger's name
logProperties - the log properties

getFormatter

protected LogFormatter getFormatter()
Returns the log event formatter.

Returns:
a log event formatter

setFormatter

protected void setFormatter(LogFormatter formatter)
Sets a new log event formatter.

Parameters:
a - log event formatter

acceptsStandardLogs

public boolean acceptsStandardLogs()
Checks if the mechanisms accepts standard logs. CRITICAL_ERROR ... TRACE level The default is to accept standard logs (true).

Returns:
true if log accepts standard records

acceptsStatisticLogs

public boolean acceptsStatisticLogs()
Checks if the mechanisms accepts statistics logs. The default is to reject statistics (false).

Returns:
true if log accepts statistic records

acceptsPerformanceLogs

public boolean acceptsPerformanceLogs()
Checks if the mechanisms accepts performance logs. The default is to accept perfromance logs (true).

Returns:
true if log accepts performance records

acceptsNotificationLogs

public boolean acceptsNotificationLogs()
Checks if the mechanisms accepts notification logs. The default is the configured notification mode from the log properties.

Returns:
true if log accepts notification records

getName

public String getName()
Return the name of the mechanism.

Returns:
The mechanism name

toString

public String toString()
Return a nice debug string.

Overrides:
toString in class Object
Returns:
A mechanism description

getActiveEntities

public List getActiveEntities()
Returns a list of all active (in use) log entities that are available by the file logging mechanisms controlled by this logger

Specified by:
getActiveEntities in interface ManageableMechanism
Returns:
a list of LogEntity objects

getReadableEntities

public List getReadableEntities()
Returns a list of all readable log entities that are available by the file logging mechanisms controlled by this logger

Specified by:
getReadableEntities in interface ManageableMechanism
Returns:
a list of log entity names

getRemoveableEntities

public List getRemoveableEntities()
Returns a list of all removeable log entities that are available by the file logging mechanisms controlled by this logger

Specified by:
getRemoveableEntities in interface ManageableMechanism
Returns:
a list of log entitiy names

removeEntity

public void removeEntity(LogEntity entity)
Remove a log entity

Specified by:
removeEntity in interface ManageableMechanism
Parameters:
String - an entity name

getReader

public LogEntityReader getReader(LogEntity entity)
Returns an entity reader for given log entity

Specified by:
getReader in interface ManageableMechanism
Parameters:
String - an entity name

createNotificationEvent

public final LogEvent createNotificationEvent(Log log,
                                              String summary,
                                              String detail)
Creates a notification log event.

Parameters:
log - A logger
summary - A notification summary (E.g. "Log closed")
detail - A notification detail
Returns:
a notification log event


This software is published under the BSD license. Copyright © 2003-2007, OMEX AG, Switzerland, All rights reserved. Use is subject to license terms.