SK.gnome.dwarf.log
Class SystemLogger

java.lang.Object
  extended bySK.gnome.dwarf.GenericService
      extended bySK.gnome.dwarf.thread.ThreadService
          extended bySK.gnome.dwarf.log.GenericLogger
              extended bySK.gnome.dwarf.log.StreamLogger
                  extended bySK.gnome.dwarf.log.SystemLogger
All Implemented Interfaces:
Logger, java.lang.Runnable, Service

public class SystemLogger
extends StreamLogger

The system console logger. It can be used to log the messages to the standard system console.


Field Summary
 
Fields inherited from class SK.gnome.dwarf.log.StreamLogger
dateTime, dateTimeFormat, extendedInfo, out
 
Fields inherited from class SK.gnome.dwarf.log.GenericLogger
facilities, levels, lock, LOG_FACILITY_ALL
 
Fields inherited from class SK.gnome.dwarf.thread.ThreadService
daemon, thread
 
Fields inherited from class SK.gnome.dwarf.GenericService
initParameters, parent
 
Fields inherited from interface SK.gnome.dwarf.Service
INITIALIZED, LOG_DEBUG, LOG_ERROR, LOG_FATAL, LOG_INFO, LOG_TRACE, LOG_WARN, LOG_XFER, SHUTDOWN, STARTED, STOPPED
 
Constructor Summary
SystemLogger(java.lang.String name)
          Creates a new SystemLogger.
 
Method Summary
static void enableLogging()
          Enables the logging only if it is disabled.
 void init(Server parent)
          Inititalizes the service and sets the output stream.
static void setLogging(boolean enable)
          Enables or disables the logging.
protected  boolean wouldLog(java.lang.String facility, LogLevel level)
          Decides whether the logger would log a message with the given loggging level and facility.
protected  void write(long time, java.lang.String facility, LogLevel level, java.lang.String message, java.lang.Throwable error)
          Writes the message to the output stream.
 
Methods inherited from class SK.gnome.dwarf.log.StreamLogger
setDateTime, setDateTimeFormat, setDateTimeFormat, setExtendedInfo
 
Methods inherited from class SK.gnome.dwarf.log.GenericLogger
enableThread, getLastAccessed, log, log, loop, setFacilities, setLevels, setMarkInterval, setRepeatedInterval, shutdown, start
 
Methods inherited from class SK.gnome.dwarf.thread.ThreadService
finish, run, setDaemon, stop
 
Methods inherited from class SK.gnome.dwarf.GenericService
getAuthenticator, getAuthFacility, getFullName, getInitParameter, getInitParameterNames, getLogFacility, getLogger, getName, getParameters, getPrincipal, getShutdownTimeout, getState, log, log, login, logout, setAuthFacility, setInitParameters, setLogFacility, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SystemLogger

public SystemLogger(java.lang.String name)
Creates a new SystemLogger.

Method Detail

setLogging

public static void setLogging(boolean enable)
Enables or disables the logging.

If set to false, all instances of this class are muted until the operation is enabled again.

If a security manager is installed, the ServicePermission "setLogging" is checked first.

Parameters:
enable - true to enable logging

enableLogging

public static void enableLogging()
Enables the logging only if it is disabled.

Calls setLogging(boolean) with true only if the logging is currently disabled.


init

public void init(Server parent)
          throws ServiceException
Inititalizes the service and sets the output stream.

The stream is set to the actual value of the System.out field.

Specified by:
init in interface Service
Overrides:
init in class GenericService
Throws:
ServiceException

wouldLog

protected boolean wouldLog(java.lang.String facility,
                           LogLevel level)
Description copied from class: StreamLogger
Decides whether the logger would log a message with the given loggging level and facility.

It first checks whether the output stream has been initialized and then calls the overriden wouldLog method and returns its result.

Overrides:
wouldLog in class StreamLogger

write

protected void write(long time,
                     java.lang.String facility,
                     LogLevel level,
                     java.lang.String message,
                     java.lang.Throwable error)
Description copied from class: StreamLogger
Writes the message to the output stream.

The time argument will be formatted according to the StreamLogger.dateTimeFormat field value if writting of the date and time information is enabled via the StreamLogger.setDateTime(boolean) method.

Overrides:
write in class StreamLogger


Copyright (c) 1999-2005, Gnome Ltd. All rights reserved.