org.openbandy.log
Class LogImpl

java.lang.Object
  extended by javax.microedition.lcdui.Displayable
      extended by javax.microedition.lcdui.Canvas
          extended by org.openbandy.log.LogImpl
All Implemented Interfaces:
java.lang.Runnable, javax.microedition.lcdui.CommandListener, Log, BandyDisplayable

public class LogImpl
extends javax.microedition.lcdui.Canvas
implements Log, BandyDisplayable, javax.microedition.lcdui.CommandListener, java.lang.Runnable

Implementation of the Log interface for use with CLDC and MIDP on mobile devices. This class can write log message to a canvas (default), the devices persistent RMS, or a file.

(c) Copyright P. Bolliger 2007, ALL RIGHTS RESERVED.

Version:
2.2
Author:
Philipp Bolliger (philipp@bolliger.name)

Field Summary
 LogConfiguration config
          The configuration of the canvas as a screen
static java.lang.String VALUE_DELIMITER
          String value to delimit values
static java.lang.String VARIABLE_DELIMITER
          String value to delimit different variables
 
Fields inherited from class javax.microedition.lcdui.Canvas
DOWN, FIRE, GAME_A, GAME_B, GAME_C, GAME_D, KEY_NUM0, KEY_NUM1, KEY_NUM2, KEY_NUM3, KEY_NUM4, KEY_NUM5, KEY_NUM6, KEY_NUM7, KEY_NUM8, KEY_NUM9, KEY_POUND, KEY_STAR, LEFT, RIGHT, UP
 
Constructor Summary
LogImpl(LogConfiguration config)
          Create a new LogImple instance and configure it accordingly
 
Method Summary
 void clearCanvas()
          Removes all log entries from canvas
 void commandAction(javax.microedition.lcdui.Command c, javax.microedition.lcdui.Displayable d)
           
 void debug(java.lang.Object origin, java.lang.String message)
          Logs a message with log level LEVEL_DEBUG
 void debug(java.lang.String originName, java.lang.String message)
          Logs a message with log level LEVEL_DEBUG
 void displayStoredLogMessages()
          Print all persistently stored log messages to the canvas.
 void error(java.lang.Object origin, java.lang.String message, java.lang.Throwable exception)
          Logs a message with log level LEVEL_ERROR
 void error(java.lang.String originName, java.lang.String message, java.lang.Throwable exception)
          Logs a message with log level LEVEL_ERROR
 java.lang.String getPersistentLogAsString(javax.microedition.lcdui.Displayable currentDisplayable)
           
 void info(java.lang.Object origin, java.lang.String message)
          Logs a message with log level LEVEL_INFO
 void info(java.lang.String originName, java.lang.String message)
          Logs a message with log level LEVEL_INFO
 void keyPressed(int key)
          Called when a key is pressed, this method handles the scrolling
 void run()
           
 void setLogLevel(int level)
          Set the log level
 void setMIDlet(javax.microedition.midlet.MIDlet midlet)
           
 void show(javax.microedition.lcdui.Display display, javax.microedition.lcdui.Displayable previousDisplayable)
          Tells the BandyDisplayable to set itself as the current screen.
 void warn(java.lang.Object origin, java.lang.String message)
          Logs a message with log level LEVEL_WARNING
 void warn(java.lang.String originName, java.lang.String message)
          Logs a message with log level LEVEL_WARNING
 
Methods inherited from class javax.microedition.lcdui.Canvas
getGameAction, getKeyCode, getKeyName, hasPointerEvents, hasPointerMotionEvents, hasRepeatEvents, isDoubleBuffered, repaint, repaint, serviceRepaints, setCommandListener, setFullScreenMode
 
Methods inherited from class javax.microedition.lcdui.Displayable
addCommand, getHeight, getTicker, getTitle, getWidth, isShown, removeCommand, setTicker, setTitle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VALUE_DELIMITER

public static final java.lang.String VALUE_DELIMITER
String value to delimit values

See Also:
Constant Field Values

VARIABLE_DELIMITER

public static final java.lang.String VARIABLE_DELIMITER
String value to delimit different variables

See Also:
Constant Field Values

config

public LogConfiguration config
The configuration of the canvas as a screen

Constructor Detail

LogImpl

public LogImpl(LogConfiguration config)
Create a new LogImple instance and configure it accordingly

Parameters:
config - The (initial) log config that shall apply to this instance
Method Detail

setMIDlet

public void setMIDlet(javax.microedition.midlet.MIDlet midlet)

error

public void error(java.lang.Object origin,
                  java.lang.String message,
                  java.lang.Throwable exception)
Logs a message with log level LEVEL_ERROR

Specified by:
error in interface Log
Parameters:
origin - The object reporting
message - The message to log
exception - The exception that was caused with this error

error

public void error(java.lang.String originName,
                  java.lang.String message,
                  java.lang.Throwable exception)
Logs a message with log level LEVEL_ERROR

Specified by:
error in interface Log
Parameters:
originName - The class name of the object reporting
message - The message to log
exception - The exception that was caused with this error

warn

public void warn(java.lang.Object origin,
                 java.lang.String message)
Logs a message with log level LEVEL_WARNING

Specified by:
warn in interface Log
Parameters:
origin - The object reporting
message - The message to log

warn

public void warn(java.lang.String originName,
                 java.lang.String message)
Logs a message with log level LEVEL_WARNING

Specified by:
warn in interface Log
Parameters:
originName - The class name of the object reporting
message - The message to log

info

public void info(java.lang.Object origin,
                 java.lang.String message)
Logs a message with log level LEVEL_INFO

Specified by:
info in interface Log
Parameters:
origin - The object reporting
message - The message to log

info

public void info(java.lang.String originName,
                 java.lang.String message)
Logs a message with log level LEVEL_INFO

Specified by:
info in interface Log
Parameters:
originName - The class name of the object reporting
message - The message to log

debug

public void debug(java.lang.Object origin,
                  java.lang.String message)
Logs a message with log level LEVEL_DEBUG

Specified by:
debug in interface Log
Parameters:
origin - The object reporting
message - The message to log

debug

public void debug(java.lang.String originName,
                  java.lang.String message)
Logs a message with log level LEVEL_DEBUG

Specified by:
debug in interface Log
Parameters:
originName - The class name of the object reporting
message - The message to log

setLogLevel

public void setLogLevel(int level)
Description copied from interface: Log
Set the log level

Specified by:
setLogLevel in interface Log
Parameters:
level - Log level according to

displayStoredLogMessages

public void displayStoredLogMessages()
Print all persistently stored log messages to the canvas.


clearCanvas

public void clearCanvas()
Removes all log entries from canvas


show

public void show(javax.microedition.lcdui.Display display,
                 javax.microedition.lcdui.Displayable previousDisplayable)
Description copied from interface: BandyDisplayable
Tells the BandyDisplayable to set itself as the current screen.

Specified by:
show in interface BandyDisplayable
Parameters:
display - The MIDlets display
previousDisplayable - The displayable that is shown before this one

keyPressed

public void keyPressed(int key)
Called when a key is pressed, this method handles the scrolling

Overrides:
keyPressed in class javax.microedition.lcdui.Canvas
Parameters:
key - number of the pressed key

commandAction

public void commandAction(javax.microedition.lcdui.Command c,
                          javax.microedition.lcdui.Displayable d)
Specified by:
commandAction in interface javax.microedition.lcdui.CommandListener

run

public void run()
Specified by:
run in interface java.lang.Runnable

getPersistentLogAsString

public java.lang.String getPersistentLogAsString(javax.microedition.lcdui.Displayable currentDisplayable)