Syslog: White Paper FAQ Examples JavaDoc
Protomatter Classes v1.1.6

com.protomatter.syslog
Class BasicLogger

java.lang.Object
  |
  +--com.protomatter.syslog.BasicLogger
All Implemented Interfaces:
Syslogger
Direct Known Subclasses:
DatabaseLog, FileLog, JMSLog, LengthRolloverLog, MailLog, OpenFileLog, PrintWriterLog, RemoteLog, TimeRolloverLog

public abstract class BasicLogger
extends java.lang.Object
implements Syslogger

A base class for Syslogger implementations. This class provides common functions for setting the date format for log entries and for formatting dates. The default policy used by this logger is the SimpleLogPolicy policy. The default text formatter is the SimpleSyslogTextFormatter formatter. If this class is used in JDK 1.4, the defauly text formatter is the JDK14SyslogTextFormatter.

See Also:
XML configuration class

Field Summary
protected  SyslogTextFormatter formatter
           
protected  LogPolicy policy
           
protected  LogPolicy realPolicy
           
 
Constructor Summary
BasicLogger()
          The default constructor -- configure() will need to be called.
 
Method Summary
protected  void formatLogEntry(java.lang.StringBuffer b, SyslogMessage message)
          Format the log entry using the current log formatter.
 java.lang.String getName()
          Get this logger's name.
 LogPolicy getPolicy()
          Get the log policy used by this logger.
 SyslogTextFormatter getTextFormatter()
          Get the log formatter object used by this logger.
 boolean isSuspended()
          Determine if this logger is suspended or not.
 boolean mightLog(java.lang.Object logger, int level, java.lang.String channel)
          Determine if it's likely that a message from the given logger at the given level on the given channel will be paid attention to.
protected  void resetDateFormat()
          Reset the text formatter's date format.
 void resume()
          Resume operations with this logger.
 void setName(java.lang.String name)
          Set this logger's name.
 void setPolicy(LogPolicy policy)
          Set the log policy used by this logger.
 void setTextFormatter(SyslogTextFormatter formatter)
          Set the log formatter object used by this logger.
protected  boolean shouldLog(SyslogMessage message)
          A utility method to see if the current log policy says we should pay attention to this message.
 void suspend()
          Suspend the operation of this logger.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.protomatter.syslog.Syslogger
flush, log, shutdown
 

Field Detail

policy

protected LogPolicy policy

realPolicy

protected LogPolicy realPolicy

formatter

protected SyslogTextFormatter formatter
Constructor Detail

BasicLogger

public BasicLogger()
The default constructor -- configure() will need to be called.
Method Detail

suspend

public void suspend()
Suspend the operation of this logger. After suspending a logger, it will no longer accept new messages. Any messages alread received an in a buffer may or may not be written.

resume

public void resume()
Resume operations with this logger. Any new messages will be processed normally.

isSuspended

public boolean isSuspended()
Determine if this logger is suspended or not.

setPolicy

public void setPolicy(LogPolicy policy)
Set the log policy used by this logger.
Specified by:
setPolicy in interface Syslogger

getPolicy

public LogPolicy getPolicy()
Get the log policy used by this logger.
Specified by:
getPolicy in interface Syslogger

mightLog

public boolean mightLog(java.lang.Object logger,
                        int level,
                        java.lang.String channel)
Determine if it's likely that a message from the given logger at the given level on the given channel will be paid attention to. This method delegates the decision to the LogPolicy that's being used. The message generated to query the policy has everything except the message, detail and hostname filled in.
Specified by:
mightLog in interface Syslogger
See Also:
LogPolicy

setTextFormatter

public void setTextFormatter(SyslogTextFormatter formatter)
Set the log formatter object used by this logger.
Specified by:
setTextFormatter in interface Syslogger

getTextFormatter

public SyslogTextFormatter getTextFormatter()
Get the log formatter object used by this logger.
Specified by:
getTextFormatter in interface Syslogger

shouldLog

protected boolean shouldLog(SyslogMessage message)
A utility method to see if the current log policy says we should pay attention to this message.

formatLogEntry

protected void formatLogEntry(java.lang.StringBuffer b,
                              SyslogMessage message)
Format the log entry using the current log formatter.
See Also:
SimpleSyslogTextFormatter

resetDateFormat

protected void resetDateFormat()
Reset the text formatter's date format. This is basically a kludge for loggers that rotate their logs.
See Also:
SyslogTextFormatter

setName

public void setName(java.lang.String name)
Set this logger's name.
Specified by:
setName in interface Syslogger

getName

public java.lang.String getName()
Get this logger's name.
Specified by:
getName in interface Syslogger

Protomatter Classes v1.1.6
Copyright 1998-2001 Nate Sammons

Protomatter Classes v1.1.6 http://protomatter.sourceforge.net/1.1.6