sam.ui
Class LogInterface

java.lang.Object
  |
  +--sam.ui.LogInterface
Direct Known Subclasses:
LogInterface

public abstract class LogInterface
extends java.lang.Object

General purpose log interface. This is an abstraction for all log events : it defines how to select the log level, to conditionnally log a new message, or to disable logging. The effective way log messages are displayed is not defined in this abstract but rather in its subclasses.

See Also:
UserInterface

Constructor Summary
protected LogInterface()
           
 
Method Summary
 void disable()
          Disables any logging.
 void enable()
          Enables logging again.
static void flush()
          Flushes any pending log message.
protected  int getLevel()
          Gets the current log level upper limit.
 void log(int level, java.lang.Class clazz, java.lang.String message)
          Logs a new event.
protected abstract  void log(java.lang.String logMessage)
          Actually handles a log message.
protected static void post(java.lang.String logMessage)
          Posts a new log message Message processing is asynchronous
 void setLevel(int level)
          Sets the log level upper limit.
static void start()
          Starts logging.
static void stop()
          Stops logging.
 void test()
          Simple test code.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LogInterface

protected LogInterface()
Method Detail

getLevel

protected int getLevel()
Gets the current log level upper limit.


setLevel

public void setLevel(int level)
Sets the log level upper limit. Negative values disable logging.

Parameters:
level - the desired log level for subsequent calls which can not be greater than Settings.Defaults.MAXIMUM_LOG_LEVEL

disable

public void disable()
Disables any logging. No more log message will be allowed until a call to enable()

See Also:
getLevel()

enable

public void enable()
Enables logging again. If a call to setLevel had been made before then that log level is reset back. Otherwise all log events are unconditionnally allowed until a call to either setLevel() or to disable()

See Also:
getLevel()

log

public void log(int level,
                java.lang.Class clazz,
                java.lang.String message)
Logs a new event. The message is actually logged if, and only if the specified log level is lower than or equal to the current log level.

Note that the Class parameter is not used in this implementation, although it is meant to control the logging authorizations on a per-class basis

Parameters:
level - the log level of this event, higher meaning lower priority
clazz - the class issuing this log eveng
message - the log message

log

protected abstract void log(java.lang.String logMessage)
Actually handles a log message. This is the very method meant to be overridden and to do the logging job.


post

protected static void post(java.lang.String logMessage)
Posts a new log message Message processing is asynchronous

See Also:
start(), stop()

start

public static void start()
Starts logging. Spawns a new thread which will log all sent log messages. Note that the actual UserInterface used to handle log messages may vary according to calls made to UserInterface.set

See Also:
UserInterface.set(java.lang.String)

flush

public static void flush()
Flushes any pending log message. This a blocking call that waits for all pending log messages to have been properly handled. Warning: in particular that this is a dead call if no call to start() was previously made.


stop

public static void stop()
Stops logging. This stops logging and flushes any pending log message. This is a blocking call.

See Also:
flush()

test

public void test()
Simple test code.