com.threed.jpct
Class Logger

java.lang.Object
  extended by com.threed.jpct.Logger

public class Logger
extends java.lang.Object

Logger is jPCT's simple logging class for printing and storing messages, errors and warnings. Every message jPCT generates will be processed by this class.


Field Summary
static int DEBUG
          A debug message
static int ERROR
          The message is an error
static int LL_DEBUG
          Log-Level: log everything including debug
static int LL_ERRORS_AND_WARNINGS
          Log-Level: log errors and warnings
static int LL_ONLY_ERRORS
          Log-Level: log errors only
static int LL_VERBOSE
          Log-Level: log everything but debug (default)
static int MESSAGE
          The message is just that: a message
static int ON_ERROR_EXIT
          Exit after an error occurs
static int ON_ERROR_RESUME_NEXT
          Try to continue even in case of an error
static int ON_ERROR_THROW_EXCEPTION
          Throw a RuntimeException in case of an error (default)
static int WARNING
          The message is a warning
 
Constructor Summary
Logger()
           
 
Method Summary
static LogHandler getLogHandler()
          Returns the current LogHandler.
static int getLogLevel()
          Returns the log-level.
static boolean isDebugEnabled()
          Returns true, if debug log level is active.
static void log(java.lang.String msg)
          Logs a message.
static void log(java.lang.String msg, int type)
          Logs a message, error or warning.
static void log(java.lang.Throwable tw)
          Logs an exception as an error.
static void log(java.lang.Throwable tw, int type)
          Logs an exception.
static void setLogHandler(LogHandler logHandler)
          Sets a new LogHandler
static void setLogLevel(int level)
          Sets the log-level.
static void setOnError(int mode)
          Sets error behaviour.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ERROR

public static final int ERROR
The message is an error

See Also:
Constant Field Values

WARNING

public static final int WARNING
The message is a warning

See Also:
Constant Field Values

MESSAGE

public static final int MESSAGE
The message is just that: a message

See Also:
Constant Field Values

DEBUG

public static final int DEBUG
A debug message

See Also:
Constant Field Values

ON_ERROR_THROW_EXCEPTION

public static final int ON_ERROR_THROW_EXCEPTION
Throw a RuntimeException in case of an error (default)

See Also:
Constant Field Values

ON_ERROR_EXIT

public static final int ON_ERROR_EXIT
Exit after an error occurs

See Also:
Constant Field Values

ON_ERROR_RESUME_NEXT

public static final int ON_ERROR_RESUME_NEXT
Try to continue even in case of an error

See Also:
Constant Field Values

LL_ONLY_ERRORS

public static final int LL_ONLY_ERRORS
Log-Level: log errors only

See Also:
Constant Field Values

LL_ERRORS_AND_WARNINGS

public static final int LL_ERRORS_AND_WARNINGS
Log-Level: log errors and warnings

See Also:
Constant Field Values

LL_VERBOSE

public static final int LL_VERBOSE
Log-Level: log everything but debug (default)

See Also:
Constant Field Values

LL_DEBUG

public static final int LL_DEBUG
Log-Level: log everything including debug

See Also:
Constant Field Values
Constructor Detail

Logger

public Logger()
Method Detail

setOnError

public static void setOnError(int mode)
Sets error behaviour. The logger can terminate the VM in case of an error, throw an exception or try to continue. Throwing an exception is default.

Parameters:
mode - the error mode
See Also:
ON_ERROR_EXIT, ON_ERROR_RESUME_NEXT, ON_ERROR_THROW_EXCEPTION

setLogLevel

public static void setLogLevel(int level)
Sets the log-level.

Parameters:
level - the log-level
See Also:
LL_ONLY_ERRORS, LL_ERRORS_AND_WARNINGS, LL_VERBOSE, LL_DEBUG

getLogLevel

public static int getLogLevel()
Returns the log-level. return the log-level

See Also:
LL_ONLY_ERRORS, LL_ERRORS_AND_WARNINGS, LL_VERBOSE, LL_DEBUG

log

public static void log(java.lang.String msg)
Logs a message. A short cut to log(, Logger.MESSAGE);

Parameters:
msg - the message

log

public static void log(java.lang.Throwable tw)
Logs an exception as an error.

Parameters:
tw - the exception

log

public static void log(java.lang.Throwable tw,
                       int type)
Logs an exception.

Parameters:
tw - the exception
type - the type of message

isDebugEnabled

public static boolean isDebugEnabled()
Returns true, if debug log level is active.


log

public static void log(java.lang.String msg,
                       int type)
Logs a message, error or warning. Errors and warnings are logged with a time-stamp.

Parameters:
msg - the message to log
type - the type of message
See Also:
ERROR, WARNING, MESSAGE, DEBUG

setLogHandler

public static void setLogHandler(LogHandler logHandler)
Sets a new LogHandler

Parameters:
logHandler - the log handler

getLogHandler

public static LogHandler getLogHandler()
Returns the current LogHandler.

Returns:
The log handler or null if none has been set