SmartFrog 3.10.000

org.smartfrog.sfcore.logging
Class LogImpl

java.lang.Object
  extended by org.smartfrog.sfcore.logging.LogImpl
All Implemented Interfaces:
java.io.Serializable, java.rmi.Remote, Log, LogLevel, LogMessage, LogRegistration, LogSF

public class LogImpl
extends java.lang.Object
implements LogSF, LogRegistration, java.io.Serializable

See Also:
Serialized Form

Field Summary
protected  int currentLogLevel
          Current log level
static java.lang.reflect.Method DEBUG_O
           
static java.lang.reflect.Method DEBUG_O_T
           
static java.lang.reflect.Method ERROR_O
           
static java.lang.reflect.Method ERROR_O_T
           
static java.lang.reflect.Method FATAL_O
           
static java.lang.reflect.Method FATAL_O_T
           
static java.lang.reflect.Method INFO_O
           
static java.lang.reflect.Method INFO_O_T
           
protected  Log localLog
          Default Log object
protected  java.lang.String logName
          Name of this log instance
protected  java.util.Hashtable registeredLogs
          Registered inputs, distribution list
static java.lang.reflect.Method TRACE_O
           
static java.lang.reflect.Method TRACE_O_T
           
static java.lang.reflect.Method WARN_O
           
static java.lang.reflect.Method WARN_O_T
           
 
Fields inherited from interface org.smartfrog.sfcore.logging.LogSF
ATR_LOG_LEVEL, ATR_LOGGER_CLASS
 
Fields inherited from interface org.smartfrog.sfcore.logging.LogLevel
LOG_LEVEL_ALL, LOG_LEVEL_DEBUG, LOG_LEVEL_ERROR, LOG_LEVEL_FATAL, LOG_LEVEL_IGNORE, LOG_LEVEL_INFO, LOG_LEVEL_OFF, LOG_LEVEL_TRACE, LOG_LEVEL_WARN
 
Constructor Summary
LogImpl(java.lang.String name)
          Constructor
LogImpl(java.lang.String name, ComponentDescription componentComponentDescription)
          Constructor
LogImpl(java.lang.String name, ComponentDescription componentComponentDescription, java.lang.Integer initialLogLevel)
          Constructor
 
Method Summary
 void debug(java.lang.Object message)
           Log a message with debug log level.
 void debug(java.lang.Object message, SmartFrogException t)
           Log an error with debug log level.
 void debug(java.lang.Object message, SmartFrogException t, TerminationRecord tr)
           Log a message with debug log level.
 void debug(java.lang.Object message, java.lang.Throwable t)
           Log an error with debug log level.
 boolean deregister(java.lang.String name)
          Log Deregistration interface
 void err(java.lang.Object message)
           Log an error with message log level.
 void err(java.lang.Object message, SmartFrogException t)
           Log an error with message log level.
 void err(java.lang.Object message, SmartFrogException t, TerminationRecord tr)
           Log a message with message log level.
 void err(java.lang.Object message, java.lang.Throwable t)
           Log an error with message log level.
 void error(java.lang.Object message)
           Log a message with error log level.
 void error(java.lang.Object message, SmartFrogException t)
           Log an error with error log level.
 void error(java.lang.Object message, SmartFrogException t, TerminationRecord tr)
           Log a message with error log level.
 void error(java.lang.Object message, java.lang.Throwable t)
           Log an error with error log level.
 void fatal(java.lang.Object message)
           Log a message with fatal log level.
 void fatal(java.lang.Object message, SmartFrogException t)
           Log an error with fatal log level.
 void fatal(java.lang.Object message, SmartFrogException t, TerminationRecord tr)
           Log a message with fatal log level.
 void fatal(java.lang.Object message, java.lang.Throwable t)
           Log an error with fatal log level.
 int getLevel()
           Get logging level.
static int getLevel(Log logger)
           Get logger level
 java.lang.String getLogName()
           Get log name.
static java.lang.reflect.Method getObjectMethod(java.lang.String method, java.lang.Class[] args)
          Gets the corresponding method of java.lang.Object.
protected  java.lang.String getSfCodeBase(ComponentDescription desc)
          Gets the class code base by resolving the sfCodeBase attribute in the given description.
 void ignore(java.lang.Object message)
           Log a message with ignore log level.
 void ignore(java.lang.Object message, SmartFrogException t)
           Log an error with ignore log level.
 void ignore(java.lang.Object message, SmartFrogException t, TerminationRecord tr)
           Log a message with ignore log level.
 void ignore(java.lang.Object message, java.lang.Throwable t)
           Log an error with ignore log level.
 void info(java.lang.Object message)
           Log a message with info log level.
 void info(java.lang.Object message, SmartFrogException t)
           Log an error with info log level.
 void info(java.lang.Object message, SmartFrogException t, TerminationRecord tr)
           Log a message with info log level.
 void info(java.lang.Object message, java.lang.Throwable t)
           Log an error with info log level.
 void invoke(java.lang.reflect.Method method, java.lang.Object[] args)
           Invokes method in localLog and registered logs.
 boolean isDebugEnabled()
           Are debug messages currently enabled?
 boolean isErrorEnabled()
           Are error messages currently enabled?
 boolean isFatalEnabled()
           Are fatal messages currently enabled?
 boolean isIgnoreEnabled()
           Is ignore logging currently enabled?
 boolean isInfoEnabled()
           Are info messages currently enabled?
 boolean isLevelEnabled(int logLevel)
          Is the given log level currently enabled?
 boolean isTraceEnabled()
           Are trace messages currently enabled?
 boolean isWarnEnabled()
           Are warn messages currently enabled?
 Log[] listRegisteredLogs()
          Get a list of all registered logs
static Log loadLogger(java.lang.String name, ComponentDescription configuration, java.lang.Integer logLevel, java.lang.String targetClassName, java.lang.String targetCodeBase)
          Dynamically loads the class that implements the selected logger
 void out(java.lang.Object message)
           Log an error with message log level.
 void register(java.lang.String name, Log log)
          Log Registration interface
 void register(java.lang.String name, Log log, int logLevel)
          Log Registration interface
 void setLevel(int currentLogLevel)
           Set logging level.
 void trace(java.lang.Object message)
           Log a message with trace log level.
 void trace(java.lang.Object message, SmartFrogException t)
           Log an error with trace log level.
 void trace(java.lang.Object message, SmartFrogException t, TerminationRecord tr)
           Log a message with trace log level.
 void trace(java.lang.Object message, java.lang.Throwable t)
           Log an error with trace log level.
 void warn(java.lang.Object message)
           Log a message with warn log level.
 void warn(java.lang.Object message, SmartFrogException t)
           Log an error with warn log level.
 void warn(java.lang.Object message, SmartFrogException t, TerminationRecord tr)
           Log a message with warn log level.
 void warn(java.lang.Object message, java.lang.Throwable t)
           Log an error with warn log level.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

localLog

protected Log localLog
Default Log object


logName

protected java.lang.String logName
Name of this log instance


currentLogLevel

protected int currentLogLevel
Current log level


TRACE_O

public static final java.lang.reflect.Method TRACE_O

TRACE_O_T

public static final java.lang.reflect.Method TRACE_O_T

DEBUG_O

public static final java.lang.reflect.Method DEBUG_O

DEBUG_O_T

public static final java.lang.reflect.Method DEBUG_O_T

INFO_O

public static final java.lang.reflect.Method INFO_O

INFO_O_T

public static final java.lang.reflect.Method INFO_O_T

WARN_O

public static final java.lang.reflect.Method WARN_O

WARN_O_T

public static final java.lang.reflect.Method WARN_O_T

ERROR_O

public static final java.lang.reflect.Method ERROR_O

ERROR_O_T

public static final java.lang.reflect.Method ERROR_O_T

FATAL_O

public static final java.lang.reflect.Method FATAL_O

FATAL_O_T

public static final java.lang.reflect.Method FATAL_O_T

registeredLogs

protected java.util.Hashtable registeredLogs
Registered inputs, distribution list

Constructor Detail

LogImpl

public LogImpl(java.lang.String name)
Constructor

Parameters:
name - for Log

LogImpl

public LogImpl(java.lang.String name,
               ComponentDescription componentComponentDescription)
Constructor

Parameters:
name - for Log
componentComponentDescription - configuration that overwrites class configuraion

LogImpl

public LogImpl(java.lang.String name,
               ComponentDescription componentComponentDescription,
               java.lang.Integer initialLogLevel)
Constructor

Parameters:
name - for Log
componentComponentDescription - configuration that overwrites class configuraion
initialLogLevel - level to log at. If null it will be ignored.
Method Detail

getObjectMethod

public static java.lang.reflect.Method getObjectMethod(java.lang.String method,
                                                       java.lang.Class[] args)
Gets the corresponding method of java.lang.Object.

Parameters:
method - A method name.
args - An array with the arguments of that method.
Returns:
A corresponding method of java.lang.Object.

invoke

public void invoke(java.lang.reflect.Method method,
                   java.lang.Object[] args)

Invokes method in localLog and registered logs.

Parameters:
method - method to call
args - args to invoke

loadLogger

public static Log loadLogger(java.lang.String name,
                             ComponentDescription configuration,
                             java.lang.Integer logLevel,
                             java.lang.String targetClassName,
                             java.lang.String targetCodeBase)
                      throws SmartFrogLogException
Dynamically loads the class that implements the selected logger

Parameters:
name - String
configuration - ComponentDescription
logLevel - Integer
targetClassName - String
targetCodeBase - String
Returns:
Log logger implementing Log interface.
Throws:
SmartFrogLogException - if failed to load

getLogName

public java.lang.String getLogName()

Get log name.

Specified by:
getLogName in interface LogSF
Returns:
log name

getSfCodeBase

protected java.lang.String getSfCodeBase(ComponentDescription desc)
Gets the class code base by resolving the sfCodeBase attribute in the given description.

Parameters:
desc - Description in which we resolve the code base.
Returns:
class code base for that description.

setLevel

public void setLevel(int currentLogLevel)

Set logging level.

Specified by:
setLevel in interface LogLevel
Specified by:
setLevel in interface LogSF
Parameters:
currentLogLevel - new logging level

getLevel

public int getLevel()

Get logging level.

Specified by:
getLevel in interface LogLevel
Specified by:
getLevel in interface LogSF
Returns:
int log level

getLevel

public static int getLevel(Log logger)

Get logger level

Parameters:
logger -
Returns:
int log level

isLevelEnabled

public boolean isLevelEnabled(int logLevel)
Is the given log level currently enabled?

Specified by:
isLevelEnabled in interface LogLevel
Parameters:
logLevel - is this level enabled?
Returns:
boolean true if given log level is currently enabled

isDebugEnabled

public final boolean isDebugEnabled()

Are debug messages currently enabled?

This allows expensive operations such as String concatenation to be avoided when the message will be ignored by the logger.

Specified by:
isDebugEnabled in interface Log
Returns:
boolean true if debug level is currently enabled

isErrorEnabled

public final boolean isErrorEnabled()

Are error messages currently enabled?

This allows expensive operations such as String concatenation to be avoided when the message will be ignored by the logger.

Specified by:
isErrorEnabled in interface Log
Returns:
boolean true if error level is currently enabled

isFatalEnabled

public final boolean isFatalEnabled()

Are fatal messages currently enabled?

This allows expensive operations such as String concatenation to be avoided when the message will be ignored by the logger.

Specified by:
isFatalEnabled in interface Log
Returns:
boolean true if fatal level is currently enabled

isInfoEnabled

public final boolean isInfoEnabled()

Are info messages currently enabled?

This allows expensive operations such as String concatenation to be avoided when the message will be ignored by the logger.

Specified by:
isInfoEnabled in interface Log
Returns:
boolean true if info level is currently enabled

isTraceEnabled

public final boolean isTraceEnabled()

Are trace messages currently enabled?

This allows expensive operations such as String concatenation to be avoided when the message will be ignored by the logger.

Specified by:
isTraceEnabled in interface Log
Returns:
boolean true if trace level is currently enabled

isWarnEnabled

public final boolean isWarnEnabled()

Are warn messages currently enabled?

This allows expensive operations such as String concatenation to be avoided when the message will be ignored by the logger.

Specified by:
isWarnEnabled in interface Log
Returns:
boolean true if warn level is currently enabled

trace

public void trace(java.lang.Object message)

Log a message with trace log level.

Specified by:
trace in interface Log
Parameters:
message - log this message

trace

public void trace(java.lang.Object message,
                  java.lang.Throwable t)

Log an error with trace log level.

Specified by:
trace in interface Log
Parameters:
message - log this message
t - log this cause

debug

public void debug(java.lang.Object message)

Log a message with debug log level.

Specified by:
debug in interface Log
Parameters:
message - log this message

debug

public void debug(java.lang.Object message,
                  java.lang.Throwable t)

Log an error with debug log level.

Specified by:
debug in interface Log
Parameters:
message - log this message
t - log this cause

info

public void info(java.lang.Object message)

Log a message with info log level.

Specified by:
info in interface Log
Parameters:
message - log this message

info

public void info(java.lang.Object message,
                 java.lang.Throwable t)

Log an error with info log level.

Specified by:
info in interface Log
Parameters:
message - log this message
t - log this cause

warn

public void warn(java.lang.Object message)

Log a message with warn log level.

Specified by:
warn in interface Log
Parameters:
message - log this message

warn

public void warn(java.lang.Object message,
                 java.lang.Throwable t)

Log an error with warn log level.

Specified by:
warn in interface Log
Parameters:
message - log this message
t - log this cause

error

public void error(java.lang.Object message)

Log a message with error log level.

Specified by:
error in interface Log
Parameters:
message - log this message

error

public void error(java.lang.Object message,
                  java.lang.Throwable t)

Log an error with error log level.

Specified by:
error in interface Log
Parameters:
message - log this message
t - log this cause

fatal

public void fatal(java.lang.Object message)

Log a message with fatal log level.

Specified by:
fatal in interface Log
Parameters:
message - log this message

fatal

public void fatal(java.lang.Object message,
                  java.lang.Throwable t)

Log an error with fatal log level.

Specified by:
fatal in interface Log
Parameters:
message - log this message
t - log this cause

isIgnoreEnabled

public boolean isIgnoreEnabled()

Is ignore logging currently enabled?

Call this method to prevent having to perform expensive operations (for example, String concatenation) when the log level is more than ignore.

Specified by:
isIgnoreEnabled in interface LogSF
Returns:
boolean

ignore

public void ignore(java.lang.Object message)

Log a message with ignore log level.

Specified by:
ignore in interface LogSF
Parameters:
message - log this message

ignore

public void ignore(java.lang.Object message,
                   java.lang.Throwable t)

Log an error with ignore log level.

Specified by:
ignore in interface LogSF
Parameters:
message - log this message
t - log this cause

ignore

public void ignore(java.lang.Object message,
                   SmartFrogException t,
                   TerminationRecord tr)

Log a message with ignore log level.

Specified by:
ignore in interface LogSF
Parameters:
message - log this message
t - log this cause
tr - log this TerminationRecord

ignore

public void ignore(java.lang.Object message,
                   SmartFrogException t)

Log an error with ignore log level.

Specified by:
ignore in interface LogSF
Parameters:
message - log this message
t - log this cause

out

public void out(java.lang.Object message)

Log an error with message log level.

Same as info messages but without Labels.

Specified by:
out in interface LogMessage
Parameters:
message - log this message

err

public void err(java.lang.Object message)

Log an error with message log level.

Same as info messages but without Labels.

Specified by:
err in interface LogMessage
Parameters:
message - log this message

err

public void err(java.lang.Object message,
                java.lang.Throwable t)

Log an error with message log level.

Same as info messages but without Labels.

Specified by:
err in interface LogMessage
Parameters:
message - log this message
t - log this cause

err

public void err(java.lang.Object message,
                SmartFrogException t,
                TerminationRecord tr)

Log a message with message log level.

Same as info messages but without Labels.

Specified by:
err in interface LogMessage
Parameters:
message - log this message
t - log this cause
tr - log this TerminationRecord

err

public void err(java.lang.Object message,
                SmartFrogException t)

Log an error with message log level.

Same as info messages but without Labels.

Specified by:
err in interface LogMessage
Parameters:
message - log this message
t - log this cause

trace

public void trace(java.lang.Object message,
                  SmartFrogException t,
                  TerminationRecord tr)

Log a message with trace log level.

Specified by:
trace in interface LogSF
Parameters:
message - log this message
t - log this cause
tr - log this TerminationRecord

trace

public void trace(java.lang.Object message,
                  SmartFrogException t)

Log an error with trace log level.

Specified by:
trace in interface LogSF
Parameters:
message - log this message
t - log this cause

debug

public void debug(java.lang.Object message,
                  SmartFrogException t,
                  TerminationRecord tr)

Log a message with debug log level.

Specified by:
debug in interface LogSF
Parameters:
message - log this message
t - log this cause
tr - log this TerminationRecord

debug

public void debug(java.lang.Object message,
                  SmartFrogException t)

Log an error with debug log level.

Specified by:
debug in interface LogSF
Parameters:
message - log this message
t - log this cause

info

public void info(java.lang.Object message,
                 SmartFrogException t,
                 TerminationRecord tr)

Log a message with info log level.

Specified by:
info in interface LogSF
Parameters:
message - log this message
t - log this cause
tr - log this TerminationRecord

info

public void info(java.lang.Object message,
                 SmartFrogException t)

Log an error with info log level.

Specified by:
info in interface LogSF
Parameters:
message - log this message
t - log this cause

warn

public void warn(java.lang.Object message,
                 SmartFrogException t,
                 TerminationRecord tr)

Log a message with warn log level.

Specified by:
warn in interface LogSF
Parameters:
message - log this message
t - log this cause
tr - log this TerminationRecord

warn

public void warn(java.lang.Object message,
                 SmartFrogException t)

Log an error with warn log level.

Specified by:
warn in interface LogSF
Parameters:
message - log this message
t - log this cause

error

public void error(java.lang.Object message,
                  SmartFrogException t,
                  TerminationRecord tr)

Log a message with error log level.

Specified by:
error in interface LogSF
Parameters:
message - log this message
t - log this cause
tr - log this TerminationRecord

error

public void error(java.lang.Object message,
                  SmartFrogException t)

Log an error with error log level.

Specified by:
error in interface LogSF
Parameters:
message - log this message
t - log this cause

fatal

public void fatal(java.lang.Object message,
                  SmartFrogException t,
                  TerminationRecord tr)

Log a message with fatal log level.

Specified by:
fatal in interface LogSF
Parameters:
message - log this message
t - log this cause
tr - log this TerminationRecord

fatal

public void fatal(java.lang.Object message,
                  SmartFrogException t)

Log an error with fatal log level.

Specified by:
fatal in interface LogSF
Parameters:
message - log this message
t - log this cause

register

public void register(java.lang.String name,
                     Log log)
              throws SmartFrogLogException,
                     java.rmi.RemoteException
Log Registration interface

Specified by:
register in interface LogRegistration
Parameters:
name - log name
log - logger to register
Throws:
SmartFrogLogException - if failed to register
java.rmi.RemoteException - in case of remote/network error

register

public void register(java.lang.String name,
                     Log log,
                     int logLevel)
              throws java.rmi.RemoteException,
                     SmartFrogLogException
Log Registration interface

Specified by:
register in interface LogRegistration
Parameters:
name - log name
log - logger to register
logLevel - log level
Throws:
java.rmi.RemoteException - in case of remote/network error
SmartFrogLogException - if failed to register

deregister

public boolean deregister(java.lang.String name)
                   throws SmartFrogLogException,
                          java.rmi.RemoteException
Log Deregistration interface

Specified by:
deregister in interface LogRegistration
Parameters:
name - log name
Returns:
boolean success/failure
Throws:
SmartFrogLogException - if failed to deregister
java.rmi.RemoteException - in case of remote/network error

listRegisteredLogs

public Log[] listRegisteredLogs()
                         throws java.rmi.RemoteException,
                                SmartFrogLogException
Get a list of all registered logs

Specified by:
listRegisteredLogs in interface LogRegistration
Returns:
a list (may be of size 0 for no logs)
Throws:
java.rmi.RemoteException
SmartFrogLogException

SmartFrog CORE 3.10.000

(C) Copyright 1998-2006 Hewlett-Packard Development Company, LP