org.norther.tammi.acorn.logger.log
Class DefaultLog

java.lang.Object
  extended by org.norther.tammi.acorn.logger.log.DefaultLog
All Implemented Interfaces:
Serializable, EventListener, Log, LoggerListener
Direct Known Subclasses:
DomainLog

public class DefaultLog
extends Object
implements Log, LoggerListener, Serializable

A default implementation of Log writing to System.out and System.err.

Author:
Ilkka Priha
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.norther.tammi.acorn.logger.log.Log
ACCESS, DEBUG, ERROR, FATAL, INFO, INTERNAL_ERROR, LEVELS, NONE, TRACE, WARN, WARNING
 
Constructor Summary
DefaultLog()
          Constructs a new log.
DefaultLog(String name)
          Constructs a new log for a named logger.
 
Method Summary
 void access(long time, String msg, Object arg)
          Logs an access message.
 void activated(LoggerEvent event)
          Notifies the object that it has been activated for a logger.
 void debug(Object msg)
          Logs a debug message.
 void debug(String msg, Object arg)
          Logs a debug message with an argument.
 void error(Object msg)
          Logs an error message.
 void error(String msg, Object arg)
          Logs an error message with an argument.
 void error(String msg, Object arg, Throwable cause)
          Logs an error message with an argument and reason.
 void fatal(Object msg)
          Logs a fatal message.
 void fatal(String msg, Object arg)
          Logs a fatal message with an argument.
 void fatal(String msg, Object arg, Throwable cause)
          Logs a fatal message with an argument and reason.
 Object getContext()
          Gets the context of this log.
 int getLevel()
          Gets the log level.
protected  Localizer getLocalizer()
          Gets the localizer.
protected  LogFactory getLogFactory()
          Gets the log factory.
 Object getLogger()
          Gets the logger of this log.
 String getLoggerName()
          Gets the logger name of this log.
 void info(Object msg)
          Logs an info message.
 void info(String msg, Object arg)
          Logs an info message with an argument.
 boolean isAccess()
          Checks whether access is enabled.
 boolean isActive()
          Checks whether this log is activated.
 boolean isDebug()
          Checks whether debug is enabled.
 boolean isError()
          Checks whether error is enabled.
 boolean isFatal()
          Checks whether fatal is enabled.
 boolean isInfo()
          Checks whether info is enabled.
 boolean isLog(int level)
          Checks whether the specified level is enabled.
 boolean isTrace()
          Checks whether trace is enabled.
 boolean isWarn()
          Checks whether warn is enabled.
 String localize(Localizer localizer, Throwable target)
          Localizes the specified exception applying the given localizer.
 String localize(Localizer localizer, Throwable target, Locale locale)
          Localizes the specified exception for the given locale applying the given localizer.
 String localize(Localizer localizer, Throwable target, Object arg)
          Localizes the specified exception with an argument applying the given localizer.
 String localize(Localizer localizer, Throwable target, Object arg, Locale locale)
          Localizes the specified exception with an argument for the given locale applying the given localizer.
 String localize(Throwable target)
          Localizes the specified exception.
 String localize(Throwable target, Locale locale)
          Localizes the specified exception for the given locale.
 String localize(Throwable target, Object arg)
          Localizes the specified exception with an argument.
 String localize(Throwable target, Object arg, Locale locale)
          Localizes the specified exception with an argument for the given locale.
 void log(int level, long time, String msg, Object arg)
          Logs a message with a specific level, date and argument.
 void log(int level, long time, String msg, Object arg, Throwable cause)
          Logs a message with a specific level, date, argument and reason.
 void log(int level, Object msg)
          Logs a message with a specific level.
 void log(int level, String msg, Object arg)
          Logs a message with a specific level and argument.
 void log(int level, String msg, Object arg, Throwable cause)
          Logs a message with a specific level, argument and reason.
 void trace(Object msg)
          Logs a trace message.
 void trace(String msg, Object arg)
          Logs a trace message with an argument.
 void warn(Object msg)
          Logs a warn message.
 void warn(String msg, Object arg)
          Logs a warn message with an argument.
 void warn(String msg, Object arg, Throwable cause)
          Logs a warn message with an argument and reason.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultLog

public DefaultLog()
Constructs a new log.


DefaultLog

public DefaultLog(String name)
Constructs a new log for a named logger.

Parameters:
name - the logger name.
Method Detail

isDebug

public boolean isDebug()
Description copied from interface: Log
Checks whether debug is enabled.

Specified by:
isDebug in interface Log
Returns:
true if enabled, false otherwise.

isTrace

public boolean isTrace()
Description copied from interface: Log
Checks whether trace is enabled.

Specified by:
isTrace in interface Log
Returns:
true if enabled, false otherwise.

isInfo

public boolean isInfo()
Description copied from interface: Log
Checks whether info is enabled.

Specified by:
isInfo in interface Log
Returns:
true if enabled, false otherwise.

isWarn

public boolean isWarn()
Description copied from interface: Log
Checks whether warn is enabled.

Specified by:
isWarn in interface Log
Returns:
true if enabled, false otherwise.

isError

public boolean isError()
Description copied from interface: Log
Checks whether error is enabled.

Specified by:
isError in interface Log
Returns:
true if enabled, false otherwise.

isFatal

public boolean isFatal()
Description copied from interface: Log
Checks whether fatal is enabled.

Specified by:
isFatal in interface Log
Returns:
true if enabled, false otherwise.

isAccess

public boolean isAccess()
Description copied from interface: Log
Checks whether access is enabled.

Specified by:
isAccess in interface Log
Returns:
true if enabled, false otherwise.

isLog

public boolean isLog(int level)
Description copied from interface: Log
Checks whether the specified level is enabled.

Specified by:
isLog in interface Log
Parameters:
level - the logging level.
Returns:
true if enabled, false otherwise.

getLevel

public int getLevel()
Description copied from interface: Log
Gets the log level.

Specified by:
getLevel in interface Log
Returns:
the logging level.

debug

public void debug(Object msg)
Description copied from interface: Log
Logs a debug message.

Specified by:
debug in interface Log
Parameters:
msg - the message to log.

debug

public void debug(String msg,
                  Object arg)
Description copied from interface: Log
Logs a debug message with an argument.

Specified by:
debug in interface Log
Parameters:
msg - the message to log.
arg - the argument or cause.

trace

public void trace(Object msg)
Description copied from interface: Log
Logs a trace message.

Specified by:
trace in interface Log
Parameters:
msg - the message to log.

trace

public void trace(String msg,
                  Object arg)
Description copied from interface: Log
Logs a trace message with an argument.

Specified by:
trace in interface Log
Parameters:
msg - the message to log.
arg - the argument or cause.

info

public void info(Object msg)
Description copied from interface: Log
Logs an info message.

Specified by:
info in interface Log
Parameters:
msg - the message to log.

info

public void info(String msg,
                 Object arg)
Description copied from interface: Log
Logs an info message with an argument.

Specified by:
info in interface Log
Parameters:
msg - the message to log.
arg - the argument or cause.

warn

public void warn(Object msg)
Description copied from interface: Log
Logs a warn message.

Specified by:
warn in interface Log
Parameters:
msg - the message to log.

warn

public void warn(String msg,
                 Object arg)
Description copied from interface: Log
Logs a warn message with an argument.

Specified by:
warn in interface Log
Parameters:
msg - the message to log.
arg - the argument or cause.

warn

public void warn(String msg,
                 Object arg,
                 Throwable cause)
Description copied from interface: Log
Logs a warn message with an argument and reason.

Specified by:
warn in interface Log
Parameters:
msg - the message to log.
arg - the argument.
cause - the cause.

error

public void error(Object msg)
Description copied from interface: Log
Logs an error message.

Specified by:
error in interface Log
Parameters:
msg - the message to log.

error

public void error(String msg,
                  Object arg)
Description copied from interface: Log
Logs an error message with an argument.

Specified by:
error in interface Log
Parameters:
msg - the message to log.
arg - the argument or cause.

error

public void error(String msg,
                  Object arg,
                  Throwable cause)
Description copied from interface: Log
Logs an error message with an argument and reason.

Specified by:
error in interface Log
Parameters:
msg - the message to log.
arg - the argument.
cause - the cause.

fatal

public void fatal(Object msg)
Description copied from interface: Log
Logs a fatal message.

Specified by:
fatal in interface Log
Parameters:
msg - the message to log.

fatal

public void fatal(String msg,
                  Object arg)
Description copied from interface: Log
Logs a fatal message with an argument.

Specified by:
fatal in interface Log
Parameters:
msg - the message to log.
arg - the argument or cause.

fatal

public void fatal(String msg,
                  Object arg,
                  Throwable cause)
Description copied from interface: Log
Logs a fatal message with an argument and reason.

Specified by:
fatal in interface Log
Parameters:
msg - the message to log.
arg - the argument.
cause - the cause.

access

public void access(long time,
                   String msg,
                   Object arg)
Description copied from interface: Log
Logs an access message.

Specified by:
access in interface Log
Parameters:
time - the time of the event.
msg - the message to log.
arg - the argument.

log

public void log(int level,
                Object msg)
Description copied from interface: Log
Logs a message with a specific level.

Specified by:
log in interface Log
Parameters:
level - the level of the message.
msg - the message to log.

log

public void log(int level,
                String msg,
                Object arg)
Description copied from interface: Log
Logs a message with a specific level and argument.

Specified by:
log in interface Log
Parameters:
level - the level of the message.
msg - the message to log.
arg - the argument or cause.

log

public void log(int level,
                String msg,
                Object arg,
                Throwable cause)
Description copied from interface: Log
Logs a message with a specific level, argument and reason.

Specified by:
log in interface Log
Parameters:
level - the level of the message.
msg - the message to log.
arg - the argument.
cause - the cause.

log

public void log(int level,
                long time,
                String msg,
                Object arg)
Description copied from interface: Log
Logs a message with a specific level, date and argument.

Specified by:
log in interface Log
Parameters:
level - the level of the message.
time - the time of the event.
msg - the message to log.
arg - the argument or cause.

log

public void log(int level,
                long time,
                String msg,
                Object arg,
                Throwable cause)
Description copied from interface: Log
Logs a message with a specific level, date, argument and reason.

Specified by:
log in interface Log
Parameters:
level - the level of the message.
time - the time of the event.
msg - the message to log.
arg - the argument.
cause - the cause.

localize

public String localize(Throwable target)
Description copied from interface: Log
Localizes the specified exception.

Specified by:
localize in interface Log
Parameters:
target - the exception.
Returns:
the localized message.

localize

public String localize(Throwable target,
                       Object arg)
Description copied from interface: Log
Localizes the specified exception with an argument.

Specified by:
localize in interface Log
Parameters:
target - the exception.
arg - the argument.
Returns:
the localized message.

localize

public String localize(Throwable target,
                       Locale locale)
Description copied from interface: Log
Localizes the specified exception for the given locale.

Specified by:
localize in interface Log
Parameters:
target - the exception.
locale - the locale.
Returns:
the localized message.

localize

public String localize(Throwable target,
                       Object arg,
                       Locale locale)
Description copied from interface: Log
Localizes the specified exception with an argument for the given locale.

Specified by:
localize in interface Log
Parameters:
target - the exception.
arg - the argument.
locale - the locale.
Returns:
the localized message.

localize

public String localize(Localizer localizer,
                       Throwable target)
Description copied from interface: Log
Localizes the specified exception applying the given localizer.

Specified by:
localize in interface Log
Parameters:
localizer - the localizer.
target - the exception.
Returns:
the localized message.

localize

public String localize(Localizer localizer,
                       Throwable target,
                       Object arg)
Description copied from interface: Log
Localizes the specified exception with an argument applying the given localizer.

Specified by:
localize in interface Log
Parameters:
localizer - the localizer.
target - the exception.
arg - the argument.
Returns:
the localized message.

localize

public String localize(Localizer localizer,
                       Throwable target,
                       Locale locale)
Description copied from interface: Log
Localizes the specified exception for the given locale applying the given localizer.

Specified by:
localize in interface Log
Parameters:
localizer - the localizer.
target - the exception.
locale - the locale.
Returns:
the localized message.

localize

public String localize(Localizer localizer,
                       Throwable target,
                       Object arg,
                       Locale locale)
Description copied from interface: Log
Localizes the specified exception with an argument for the given locale applying the given localizer.

The message is constructed by using the exception type and non-localized message as a key for the localized message. If such a message can't be found, the plain exception type is used as the key. If such a message is found and it ends with a colon, the non-localized message is appended to it. If such a message is not found, the non-localized message is returned unmodified.

Specified by:
localize in interface Log
Parameters:
localizer - the localizer.
target - the exception.
arg - the argument.
locale - the locale.
Returns:
the localized message.

getLoggerName

public String getLoggerName()
Description copied from interface: Log
Gets the logger name of this log.

Specified by:
getLoggerName in interface Log
Returns:
the logger name.

getLogger

public Object getLogger()
Description copied from interface: Log
Gets the logger of this log.

Specified by:
getLogger in interface Log
Returns:
the logger.

getContext

public Object getContext()
Description copied from interface: Log
Gets the context of this log.

Specified by:
getContext in interface Log
Returns:
the context.

isActive

public boolean isActive()
Description copied from interface: Log
Checks whether this log is activated.

Specified by:
isActive in interface Log
Returns:
true if activated, false otherwise.

activated

public void activated(LoggerEvent event)
Description copied from interface: LoggerListener
Notifies the object that it has been activated for a logger.

Specified by:
activated in interface LoggerListener
Parameters:
event - the logger event.

getLogFactory

protected LogFactory getLogFactory()
Gets the log factory.

Returns:
the log factory or null.

getLocalizer

protected Localizer getLocalizer()
Gets the localizer.

Returns:
the localizer or null.


Copyright © 2004 The Norther Organization. All rights reserved.