|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object SK.gnome.dwarf.GenericService SK.gnome.dwarf.thread.ThreadService SK.gnome.dwarf.log.GenericLogger SK.gnome.dwarf.log.StreamLogger
The abstract stream logger.
This is a logger which writes log messages to an output stream.
Subclasses must override the GenericService.init(Server)
method to initialize properly
the out
field as well as the GenericLogger.shutdown()
method to flush and close the stream.
Field Summary | |
protected boolean |
dateTime
Whether to write the date and time information to the stream. |
protected java.text.DateFormat |
dateTimeFormat
The date/time format used to format the timestamp of the log messages. |
protected boolean |
extendedInfo
Whether or not to write the logging facility and level to the stream. |
protected java.io.PrintStream |
out
The output stream. |
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 | |
StreamLogger(java.lang.String name)
Creates a new StreamLogger. |
Method Summary | |
void |
setDateTime(boolean enable)
Enables or disables the writting of the date and time information. |
void |
setDateTimeFormat(java.lang.String format)
Sets the date/time format. |
void |
setDateTimeFormat(java.lang.String format,
java.lang.String language,
java.lang.String country)
Sets the date/time format with the given locale. |
void |
setExtendedInfo(boolean enable)
Enables or disables the writting of the logging level and facility. |
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.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, init, 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 |
Field Detail |
protected java.text.DateFormat dateTimeFormat
Access to this value from within a subclass must be synchronized on the GenericLogger.lock
object.
The default value is defined by the LogConstants.LOG_DEFAULT_DATETIME_FORMAT
string.
setDateTimeFormat(String)
protected boolean dateTime
Default value: true
setDateTime(boolean)
protected boolean extendedInfo
Default value: false
setExtendedInfo(boolean)
protected java.io.PrintStream out
write(long, String, LogLevel, String, Throwable)
Constructor Detail |
public StreamLogger(java.lang.String name)
Method Detail |
public void setDateTimeFormat(java.lang.String format)
The format will be based on the US locale.
format
- the date/time formatdateTimeFormat
public void setDateTimeFormat(java.lang.String format, java.lang.String language, java.lang.String country)
The format will be based on a locale created from the given language and country arguments.
format
- the date/time formatlanguage
- the languagecountry
- the countrydateTimeFormat
public void setDateTime(boolean enable)
enable
- true if the date/time info should be writtendateTime
public void setExtendedInfo(boolean enable)
enable
- true if the extended info should be writtenextendedInfo
protected boolean wouldLog(java.lang.String facility, LogLevel level)
It first checks whether the output stream has been initialized and then calls the overriden wouldLog method and returns its result.
wouldLog
in class GenericLogger
facility
- the logging facilitylevel
- the logging level
protected void write(long time, java.lang.String facility, LogLevel level, java.lang.String message, java.lang.Throwable error)
The time argument will be formatted according to the dateTimeFormat
field value if writting of the date and time information is enabled via the
setDateTime(boolean)
method.
write
in class GenericLogger
time
- the current time of the logged eventfacility
- the log facilitylevel
- the log levelmessage
- the messageerror
- the error (optional)GenericLogger.log(String, LogLevel, String)
,
GenericLogger.log(String, LogLevel, String, Throwable)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |