org.openbandy.log
Class LogConfiguration

java.lang.Object
  extended by org.openbandy.log.LogConfiguration

public class LogConfiguration
extends java.lang.Object

The LogConfiguration contains presets, defaults and preference values used to configure the behaviour of the Log. It provides two standard sets of configuration: the default log screen config and the persistent log viewer config that is suitable if the log is just used to display persistenly stored log messages in a auxiliary midlet. Presets the user is well aware of such as the log level or the log modes are stored as preference.

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

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

Field Summary
static java.lang.String LOG_FILE_NAME
          The name of the log file that is sent to the remote device or stored in the local file system
 
Constructor Summary
LogConfiguration()
           
 
Method Summary
static LogConfiguration getLogAsAppScreenConfig(boolean loadPreferences)
          Returns a configuration of the log suitable for use as an application screen within a MIdlet.
 int getLogLevel()
          Get log level currently set.
static LogConfiguration getPersistentLogViewerConfig(boolean loadPreferences)
          Returns a configuration suitable when using the log canvas as single screen to show persistently stored log messages.
 boolean logModeCanvasEnabled()
          Checks whether the log messages should be sent to the canvas.
 boolean logModeFileEnabled()
          Checks whether the log messages should be sent to the file LOG_FILE_NAME.
 boolean logModePersistentEnabled()
          Checks whether the log messages should be sent to the RMS.
 boolean logModeRemoteEnabled()
          Checks whether the log messages should be sent to a remote machine.
 void setFilterLevel(int level, boolean enabled)
          Enable and disable respectively the filter for a given log level and store it as a preference.
 void setLogLevel(int logLevel)
          Set the log level to logLevel and store it as a preference.
 void setLogMode(int mode, boolean enabled)
          Enable and disable respectively the modes[mode] and store it as a preference.
 void setMaxCanvasLogEntries(int maxLogEntries)
          Set the maximum number of entries that are displayed on the log canvas.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG_FILE_NAME

public static final java.lang.String LOG_FILE_NAME
The name of the log file that is sent to the remote device or stored in the local file system

See Also:
Constant Field Values
Constructor Detail

LogConfiguration

public LogConfiguration()
Method Detail

getLogAsAppScreenConfig

public static LogConfiguration getLogAsAppScreenConfig(boolean loadPreferences)
Returns a configuration of the log suitable for use as an application screen within a MIdlet.

Parameters:
loadPreferences - If true, preference values are loaded if available
Returns:
The LogConfiguration

getPersistentLogViewerConfig

public static LogConfiguration getPersistentLogViewerConfig(boolean loadPreferences)
Returns a configuration suitable when using the log canvas as single screen to show persistently stored log messages. This configuration turns off all logging.

Parameters:
loadPreferences - If true, preference values are loaded if available
Returns:
The LogConfiguration

setLogLevel

public void setLogLevel(int logLevel)
                 throws java.lang.Exception
Set the log level to logLevel and store it as a preference.

Parameters:
logLevel - log level to set
Throws:
java.lang.Exception
See Also:
LogLevel

getLogLevel

public int getLogLevel()
Get log level currently set.

Returns:
The currently set log level

setLogMode

public void setLogMode(int mode,
                       boolean enabled)
                throws java.lang.Exception
Enable and disable respectively the modes[mode] and store it as a preference.

Parameters:
mode - Mode indicator (MODE_CANVAS | MODE_PERSISTENT | MODE_FILE | MODE_REMOTE)
enabled - Enabled if true, disabled else
Throws:
java.lang.Exception

setFilterLevel

public void setFilterLevel(int level,
                           boolean enabled)
                    throws java.lang.Exception
Enable and disable respectively the filter for a given log level and store it as a preference.

Parameters:
level - Log level to which the filter applies
enabled - Enabled if true, disabled else
Throws:
java.lang.Exception

setMaxCanvasLogEntries

public void setMaxCanvasLogEntries(int maxLogEntries)
Set the maximum number of entries that are displayed on the log canvas.

Parameters:
maxLogEntries - Maximum entries on log canvas

logModeCanvasEnabled

public boolean logModeCanvasEnabled()
Checks whether the log messages should be sent to the canvas.

Returns:
True if canvas mode is enabled

logModePersistentEnabled

public boolean logModePersistentEnabled()
Checks whether the log messages should be sent to the RMS.

Returns:
True if persistent mode is enabled

logModeFileEnabled

public boolean logModeFileEnabled()
Checks whether the log messages should be sent to the file LOG_FILE_NAME.

Returns:
True if file mode is enabled

logModeRemoteEnabled

public boolean logModeRemoteEnabled()
Checks whether the log messages should be sent to a remote machine.

Returns:
True if remote mode is enabled