org.openbandy.log
Class LogHelper

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

public class LogHelper
extends java.lang.Object

The LogHelper provides two static methods to create log messages and determine the log level respectively. The log level is thus included as a number according to LogLevel and added at the beginning of the log message String.

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

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

Constructor Summary
LogHelper()
           
 
Method Summary
static java.lang.String createLogMessage(int level, java.lang.Object message, java.lang.String originClassName, java.lang.Throwable exception)
          Create the log message string from the given parameters according to the format: level(1)|timestamp(17)| |class name (if given)|: |log message
static int getLogLevel(java.lang.String logMessage)
          This method extracts the log level from the log message, if logMessage is formatted as: level(1)|timestamp(17)| |class name (if given)|: |log message
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LogHelper

public LogHelper()
Method Detail

createLogMessage

public static java.lang.String createLogMessage(int level,
                                                java.lang.Object message,
                                                java.lang.String originClassName,
                                                java.lang.Throwable exception)
Create the log message string from the given parameters according to the format: level(1)|timestamp(17)| |class name (if given)|: |log message

Parameters:
level - The log level that should be applied
message - The message to log
originClassName - The short class name (i.e. without package indication) of the class that logs
exception - The exception that was caused with this error, or null if it is not an error log
Returns:
The compiled log message

getLogLevel

public static int getLogLevel(java.lang.String logMessage)
This method extracts the log level from the log message, if logMessage is formatted as: level(1)|timestamp(17)| |class name (if given)|: |log message

Parameters:
logMessage - The log message, starting with an indicator of the log level
Returns:
The log level as encoded if valid, or LogLevel.DEFAULT else