net.sf.btw.commons
Class Logger

java.lang.Object
  extended by javax.microedition.lcdui.Displayable
      extended by javax.microedition.lcdui.Screen
          extended by javax.microedition.lcdui.Form
              extended by net.sf.btw.commons.Logger
All Implemented Interfaces:
CommandListener

public final class Logger
extends Form
implements CommandListener

Able to log application status.

Author:
Martin Vysny

Field Summary
static int CURRENT_LEVEL
          Current log level.
static boolean ENABLE_CONSOLE
          If true then the original System.out is used to print log aswell.
static int LEVEL_DEBUG
          Debug log level.
static int LEVEL_ERROR
          Error log level.
static int LEVEL_INFO
          Info log level.
static int LEVEL_WARNING
          Warning log level.
 
Constructor Summary
Logger(Displayable previous, Display display)
          Constructs new logger form, immediately switching to the form.
 
Method Summary
 void commandAction(Command arg0, Displayable arg1)
           
static void debug(String message, Throwable ex)
          Logs an debug message.
static void error(String message, Throwable ex)
          Logs an error message.
static void info(String message, Throwable ex)
          Logs an info message.
static boolean isLoggable(int level)
          Checks if given level is loggable with current log level setting.
static void log(int level, String message, Throwable ex)
          Logs given event.
static void warn(String message, Throwable ex)
          Logs an warning message.
 
Methods inherited from class javax.microedition.lcdui.Form
append, append, append, delete, deleteAll, get, getHeight, getWidth, insert, set, setItemStateListener, size
 
Methods inherited from class javax.microedition.lcdui.Displayable
addCommand, getTicker, getTitle, isShown, removeCommand, setCommandListener, setTicker, setTitle, sizeChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LEVEL_ERROR

public static final int LEVEL_ERROR
Error log level.

See Also:
Constant Field Values

LEVEL_WARNING

public static final int LEVEL_WARNING
Warning log level.

See Also:
Constant Field Values

LEVEL_INFO

public static final int LEVEL_INFO
Info log level.

See Also:
Constant Field Values

LEVEL_DEBUG

public static final int LEVEL_DEBUG
Debug log level.

See Also:
Constant Field Values

CURRENT_LEVEL

public static int CURRENT_LEVEL
Current log level. Log events below this level are ignored. Default value is LEVEL_WARNING.


ENABLE_CONSOLE

public static boolean ENABLE_CONSOLE
If true then the original System.out is used to print log aswell.

Constructor Detail

Logger

public Logger(Displayable previous,
              Display display)
Constructs new logger form, immediately switching to the form.

Parameters:
previous - switch to this displayable when the log window is closed.
display - the display instance
Method Detail

isLoggable

public static boolean isLoggable(int level)
Checks if given level is loggable with current log level setting.

Parameters:
level - level to query
Returns:
true if a message with given level is logged, false if it is thrown away.

log

public static void log(int level,
                       String message,
                       Throwable ex)
Logs given event.

Parameters:
level - the log level.
message - the message to log. May be null - in this case exception message is used.
ex - exception to log. May be null only if message is not null.

info

public static void info(String message,
                        Throwable ex)
Logs an info message.

Parameters:
message - the message to log. May be null - in this case exception message is used.
ex - exception to log. May be null only if message is not null.

error

public static void error(String message,
                         Throwable ex)
Logs an error message.

Parameters:
message - the message to log. May be null - in this case exception message is used.
ex - exception to log. May be null only if message is not null.

warn

public static void warn(String message,
                        Throwable ex)
Logs an warning message.

Parameters:
message - the message to log. May be null - in this case exception message is used.
ex - exception to log. May be null only if message is not null.

debug

public static void debug(String message,
                         Throwable ex)
Logs an debug message.

Parameters:
message - the message to log. May be null - in this case exception message is used.
ex - exception to log. May be null only if message is not null.

commandAction

public void commandAction(Command arg0,
                          Displayable arg1)
Specified by:
commandAction in interface CommandListener


Copyright © 2007 Moto a Judas. All Rights Reserved.