things.common.commands
Class CommandLogger

java.lang.Object
  extended by things.common.commands.CommandLogger
All Implemented Interfaces:
Debuggable, StringPoster, Logger

public class CommandLogger
extends java.lang.Object
implements Logger

Command logger. It is a wrapper around the simple Thinger logger.

Version:
1.0

Version History

EPG - Initial - 10 AUG 06
 
Author:
Erich P. Gatejen

Nested Class Summary
 
Nested classes/interfaces inherited from interface things.thinger.io.Logger
Logger.LEVEL, Logger.TYPE
 
Constructor Summary
CommandLogger()
           
 
Method Summary
 CommandLogger clone(java.lang.String tag)
          Create a clone of this logger, but with a new tag.
 void debug(java.lang.String msg)
          Log a trivial debug entry.
 void debug(java.lang.String msg, int numeric)
          Log a trivial error entry with a numeric.
 void debug(java.lang.String msg, int numeric, java.util.Collection<NVImmutable> attributes)
          Log a complex debug entry with numerics and attributes.
 void debug(java.lang.String msg, int numeric, NVImmutable... attributes)
          Log a complex debug entry with numerics and attributes.
 void debug(java.lang.String msg, int numeric, java.lang.String... attributes)
          Log a complex debug entry with numerics and attributes.
 void debuggingOff()
          Turn debugging off.
 void debuggingOn()
          Turn debugging on.
 boolean debuggingState()
          Get the current debugging state.
 void error(java.lang.String msg)
          Log a trivial error entry.
 void error(java.lang.String msg, int numeric)
          Log a trivial error entry with a numeric.
 void error(java.lang.String msg, int numeric, java.util.Collection<NVImmutable> attributes)
          Log a complex error entry with numerics and attributes.
 void error(java.lang.String msg, int numeric, NVImmutable... attributes)
          Log a complex error entry with numerics and attributes.
 void error(java.lang.String msg, int numeric, java.lang.String... attributes)
          Log a complex error entry with numerics and attributes.
 void exception(java.lang.Throwable tr)
          Log an exception.
 void flush()
          Tell the underlying system to flush any entries.
 Logger.LEVEL getLevel()
          This will get the level of entries that will pass.
 void info(java.lang.String msg)
          Log a trivial information entry.
 void info(java.lang.String msg, int numeric)
          Log a trivial information entry with a numeric.
 void info(java.lang.String msg, int numeric, java.util.Collection<NVImmutable> attributes)
          Log a complex information entry with numerics and attributes.
 void info(java.lang.String msg, int numeric, NVImmutable... attributes)
          Log a complex information entry with numerics and attributes.
 void info(java.lang.String msg, int numeric, java.lang.String... attributes)
          Log a complex info entry with numerics and attributes.
 void init(Logger.TYPE loggerType)
          Initialized the logger.
 void init(Logger logger, java.lang.String tag, Logger.LEVEL level)
          Initialize the LoggerWriter with a Writer and a prefix ID.
 void init(java.io.PrintWriter out, java.lang.String tag, Logger.LEVEL level)
          Initialize the LoggerWriter with a Writer and a prefix ID.
 void post(Entry e)
          Post an Entry.
 void post(java.lang.String message)
          Post as a message.
 void postit(java.lang.String message)
          Post as a message.
 void setLevel(Logger.LEVEL newLevel)
          This will set the level of entries that will pass.
 void setPostLevel(Logger.LEVEL newLevel)
          This will set the default level of StringPoster posted entries.
 void shout(java.lang.String msg, int numeric, Logger.LEVEL theLevel)
          Shout a log entry with numerics.
 void shout(java.lang.String msg, int numeric, Logger.LEVEL theLevel, java.util.Collection<NVImmutable> attributes)
          Shout a log entry with numerics and attributes.
 void shout(java.lang.String msg, int numeric, Logger.LEVEL theLevel, NVImmutable... attributes)
          Shout a log entry with numerics and attributes.
 void shout(java.lang.String msg, int numeric, Logger.LEVEL theLevel, java.lang.String... attributes)
          Shout a log entry with numerics and attributes.
 void shout(java.lang.String msg, Logger.LEVEL theLevel)
          Shout a log entry.
 void warning(java.lang.String msg)
          Log a trivial warning entry.
 void warning(java.lang.String msg, int numeric)
          Log a trivial warning entry with a numeric.
 void warning(java.lang.String msg, int numeric, java.util.Collection<NVImmutable> attributes)
          Log a complex warning entry with numerics and attributes.
 void warning(java.lang.String msg, int numeric, NVImmutable... attributes)
          Log a complex warning entry with numerics and attributes.
 void warning(java.lang.String msg, int numeric, java.lang.String... attributes)
          Log a complex warning entry with numerics and attributes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandLogger

public CommandLogger()
Method Detail

init

public void init(java.io.PrintWriter out,
                 java.lang.String tag,
                 Logger.LEVEL level)
          throws SystemException
Initialize the LoggerWriter with a Writer and a prefix ID. The prefix ID will be overridden by a conduit ID, if a PushDrain tries to initialize this.
You cannot call this more than once.

Parameters:
out - A writer. The implementation doesn't care what kind. If the Logger type is set as reliable, then every write will be flushed.
tag - A tag for the line.
level - The logging level. Note that the debug methods will override any value passed here.
Throws:
SystemException

init

public void init(Logger logger,
                 java.lang.String tag,
                 Logger.LEVEL level)
          throws SystemException
Initialize the LoggerWriter with a Writer and a prefix ID. The prefix ID will be overridden by a conduit ID, if a PushDrain tries to initialize this.
You cannot call this more than once.

Parameters:
logger - A logger where to post. The implementation doesn't care what kind. If the Logger type is set as reliable, then every write will be flushed.
tag - A tag for the line.
level - The logging level. Note that the debug methods will override any value passed here.
Throws:
SystemException

clone

public CommandLogger clone(java.lang.String tag)
                    throws SystemException
Create a clone of this logger, but with a new tag. It'll log to the same place as the original, but the tag will be different. All the methods (like level) will be independent. It must be init'd already..

Parameters:
tag - A tag for the line.
Returns:
the clone.
Throws:
SystemException

post

public void post(java.lang.String message)
          throws ThingsException
Post as a message.

Specified by:
post in interface StringPoster
Parameters:
message - String to post
Throws:
ThingsException

postit

public void postit(java.lang.String message)
Post as a message. Best effort. Ignore errors.

Specified by:
postit in interface StringPoster
Parameters:
message - String to post

setLevel

public void setLevel(Logger.LEVEL newLevel)
This will set the level of entries that will pass. It starts at whatever the implementation sets during construction.

Specified by:
setLevel in interface Logger
Parameters:
newLevel - the new level.

getLevel

public Logger.LEVEL getLevel()
This will get the level of entries that will pass. It starts at whatever the implementation sets during construction.

Specified by:
getLevel in interface Logger
Returns:
the level.

setPostLevel

public void setPostLevel(Logger.LEVEL newLevel)
This will set the default level of StringPoster posted entries. The default starts as DATA. That means, all posted strings will be treated as DATA level.

Specified by:
setPostLevel in interface Logger
Parameters:
newLevel - the new default level.
Throws:
SystemException

init

public void init(Logger.TYPE loggerType)
          throws SystemException
Initialized the logger. This will be done by the constructing system, typically the System or Kernel, so most users should not call this directly.

Specified by:
init in interface Logger
Parameters:
loggerType - The type of logger this should be. This is more a request than a demand.
Throws:
SystemException

debuggingOn

public void debuggingOn()
Turn debugging on. Logs with debug level priority will be passed.

Specified by:
debuggingOn in interface Debuggable

debuggingOff

public void debuggingOff()
Turn debugging off. Logs with debug level priority will not be passed.

Specified by:
debuggingOff in interface Debuggable

debuggingState

public boolean debuggingState()
Get the current debugging state.

Specified by:
debuggingState in interface Debuggable
Returns:
debugging state

flush

public void flush()
Tell the underlying system to flush any entries.

Specified by:
flush in interface StringPoster
Specified by:
flush in interface Logger

post

public void post(Entry e)
          throws SystemException
Post an Entry.

Specified by:
post in interface Logger
Parameters:
e - The entry.
Throws:
SystemException
See Also:
Entry

exception

public void exception(java.lang.Throwable tr)
               throws SystemException
Log an exception. The implementation should try to deal with the ThingsException features.

Specified by:
exception in interface Logger
Parameters:
tr - The Exception.
Throws:
SystemException

error

public void error(java.lang.String msg)
           throws SystemException
Log a trivial error entry.

Specified by:
error in interface Logger
Parameters:
msg - The text message.
Throws:
SystemException

error

public void error(java.lang.String msg,
                  int numeric)
           throws SystemException
Log a trivial error entry with a numeric.

Specified by:
error in interface Logger
Parameters:
msg - The text message.
numeric - The numeric.
Throws:
SystemException

error

public void error(java.lang.String msg,
                  int numeric,
                  NVImmutable... attributes)
           throws SystemException
Log a complex error entry with numerics and attributes.

Specified by:
error in interface Logger
Parameters:
msg - The text message.
numeric - The numeric.
attributes - Sequence of NVs representing attributes.
Throws:
SystemException
See Also:
NVImmutable

error

public void error(java.lang.String msg,
                  int numeric,
                  java.util.Collection<NVImmutable> attributes)
           throws SystemException
Log a complex error entry with numerics and attributes.

Specified by:
error in interface Logger
Parameters:
msg - The text message.
numeric - The numeric.
attributes - Sequence of NVs representing attributes.
Throws:
SystemException
See Also:
NVImmutable

error

public void error(java.lang.String msg,
                  int numeric,
                  java.lang.String... attributes)
           throws SystemException
Log a complex error entry with numerics and attributes.

Specified by:
error in interface Logger
Parameters:
msg - The text message.
numeric - The numeric.
attributes - Name/value pairs for attributes. Must be an even number of Strings.
Throws:
SystemException
See Also:
NV

warning

public void warning(java.lang.String msg)
             throws SystemException
Log a trivial warning entry.

Specified by:
warning in interface Logger
Parameters:
msg - The text message.
Throws:
SystemException

warning

public void warning(java.lang.String msg,
                    int numeric)
             throws SystemException
Log a trivial warning entry with a numeric.

Specified by:
warning in interface Logger
Parameters:
msg - The text message.
numeric - The numeric.
Throws:
SystemException

warning

public void warning(java.lang.String msg,
                    int numeric,
                    NVImmutable... attributes)
             throws SystemException
Log a complex warning entry with numerics and attributes.

Specified by:
warning in interface Logger
Parameters:
msg - The text message.
numeric - The numeric.
attributes - Sequence of NVs representing attributes.
Throws:
SystemException
See Also:
NVImmutable

warning

public void warning(java.lang.String msg,
                    int numeric,
                    java.util.Collection<NVImmutable> attributes)
             throws SystemException
Log a complex warning entry with numerics and attributes.

Specified by:
warning in interface Logger
Parameters:
msg - The text message.
numeric - The numeric.
attributes - Sequence of NVs representing attributes.
Throws:
SystemException
See Also:
NVImmutable

warning

public void warning(java.lang.String msg,
                    int numeric,
                    java.lang.String... attributes)
             throws SystemException
Log a complex warning entry with numerics and attributes.

Specified by:
warning in interface Logger
Parameters:
msg - The text message.
numeric - The numeric.
attributes - Name/value pairs for attributes. Must be an even number of Strings.
Throws:
SystemException

info

public void info(java.lang.String msg)
          throws SystemException
Log a trivial information entry.

Specified by:
info in interface Logger
Parameters:
msg - The text message.
Throws:
SystemException

info

public void info(java.lang.String msg,
                 int numeric)
          throws SystemException
Log a trivial information entry with a numeric.

Specified by:
info in interface Logger
Parameters:
msg - The text message.
numeric - The numeric.
Throws:
SystemException

info

public void info(java.lang.String msg,
                 int numeric,
                 NVImmutable... attributes)
          throws SystemException
Log a complex information entry with numerics and attributes.

Specified by:
info in interface Logger
Parameters:
msg - The text message.
numeric - The numeric.
attributes - Sequence of NVs representing attributes.
Throws:
SystemException
See Also:
NVImmutable

info

public void info(java.lang.String msg,
                 int numeric,
                 java.util.Collection<NVImmutable> attributes)
          throws SystemException
Log a complex information entry with numerics and attributes.

Specified by:
info in interface Logger
Parameters:
msg - The text message.
numeric - The numeric.
attributes - Sequence of NVs representing attributes.
Throws:
SystemException
See Also:
NVImmutable

info

public void info(java.lang.String msg,
                 int numeric,
                 java.lang.String... attributes)
          throws SystemException
Log a complex info entry with numerics and attributes.

Specified by:
info in interface Logger
Parameters:
msg - The text message.
numeric - The numeric.
attributes - Name/value pairs for attributes. Must be an even number of Strings.
Throws:
SystemException

debug

public void debug(java.lang.String msg)
           throws SystemException
Log a trivial debug entry.

Specified by:
debug in interface Logger
Parameters:
msg - The text message.
Throws:
SystemException

debug

public void debug(java.lang.String msg,
                  int numeric)
           throws SystemException
Log a trivial error entry with a numeric.

Specified by:
debug in interface Logger
Parameters:
msg - The text message.
numeric - The numeric.
Throws:
SystemException

debug

public void debug(java.lang.String msg,
                  int numeric,
                  NVImmutable... attributes)
           throws SystemException
Log a complex debug entry with numerics and attributes.

Specified by:
debug in interface Logger
Parameters:
msg - The text message.
numeric - The numeric.
attributes - Sequence of NVs representing attributes.
Throws:
SystemException
See Also:
NVImmutable

debug

public void debug(java.lang.String msg,
                  int numeric,
                  java.util.Collection<NVImmutable> attributes)
           throws SystemException
Log a complex debug entry with numerics and attributes.

Specified by:
debug in interface Logger
Parameters:
msg - The text message.
numeric - The numeric.
attributes - Sequence of NVs representing attributes.
Throws:
SystemException
See Also:
NVImmutable

debug

public void debug(java.lang.String msg,
                  int numeric,
                  java.lang.String... attributes)
           throws SystemException
Log a complex debug entry with numerics and attributes.

Specified by:
debug in interface Logger
Parameters:
msg - The text message.
numeric - The numeric.
attributes - Name/value pairs for attributes. Must be an even number of Strings.
Throws:
SystemException
See Also:
NV

shout

public void shout(java.lang.String msg,
                  Logger.LEVEL theLevel)
Shout a log entry. This is best effort and it will never return an exception.

Specified by:
shout in interface Logger
Parameters:
msg - The text message.
theLevel - The level of the message.

shout

public void shout(java.lang.String msg,
                  int numeric,
                  Logger.LEVEL theLevel)
Shout a log entry with numerics. This is best effort and it will never return an exception.

Specified by:
shout in interface Logger
Parameters:
msg - The text message.
numeric - The numeric.
theLevel - The level of the message.
See Also:
NV

shout

public void shout(java.lang.String msg,
                  int numeric,
                  Logger.LEVEL theLevel,
                  NVImmutable... attributes)
Shout a log entry with numerics and attributes. This is best effort and it will never return an exception.

Specified by:
shout in interface Logger
Parameters:
msg - The text message.
numeric - The numeric.
theLevel - The level of the message.
attributes - Sequence of NVs representing attributes.
See Also:
NVImmutable

shout

public void shout(java.lang.String msg,
                  int numeric,
                  Logger.LEVEL theLevel,
                  java.util.Collection<NVImmutable> attributes)
Shout a log entry with numerics and attributes. This is best effort and it will never return an exception.

Specified by:
shout in interface Logger
Parameters:
msg - The text message.
numeric - The numeric.
theLevel - The level of the message.
attributes - Sequence of NVs representing attributes.
See Also:
NVImmutable

shout

public void shout(java.lang.String msg,
                  int numeric,
                  Logger.LEVEL theLevel,
                  java.lang.String... attributes)
Shout a log entry with numerics and attributes. This is best effort and it will never return an exception.

Specified by:
shout in interface Logger
Parameters:
msg - The text message.
numeric - The numeric.
theLevel - The level of the message.
attributes - Name/value pairs for attributes. Must be an even number of Strings.
See Also:
NV


Things.