com.threed.jpct
Class Logger

java.lang.Object
  extended bycom.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 boolean DISCARD_MESSAGES
          Don't store the messages
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 (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 (default)
static int ON_ERROR_THROW_EXCEPTION
          Throw a RuntimeException in case of an error
static boolean STORE_MESSAGES
          Store logged messages in an internal message-buffer
static int WARNING
          The message is a warning
 
Constructor Summary
Logger()
           
 
Method Summary
static int getLogLevel()
          Returns the log-level.
static java.lang.String[] getMessageBuffer()
          Returns the current message-buffer as String-array.
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 setLogLevel(int level)
          Sets the log-level.
static void setMessageBuffer(boolean mode)
          Sets the message-buffer to store messages or to discard them after logging.
static void setOnError(int mode)
          Sets error behaviour.
static void setOutputBuffering(int rows)
          Sets how many messages should be stored in the message buffer before they are printed out.
static void setPrintStream(java.io.PrintStream ps)
          Sets the logging PrintStream.
 
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

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 (default)

See Also:
Constant Field Values

STORE_MESSAGES

public static final boolean STORE_MESSAGES
Store logged messages in an internal message-buffer

See Also:
Constant Field Values

DISCARD_MESSAGES

public static final boolean DISCARD_MESSAGES
Don't store the messages

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 (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

setPrintStream

public static void setPrintStream(java.io.PrintStream ps)
Sets the logging PrintStream. System.out is used if nothing is set here.

Parameters:
ps - the Printstream to log into

setOutputBuffering

public static void setOutputBuffering(int rows)
Sets how many messages should be stored in the message buffer before they are printed out. Default is 1, which means that every message is logged immediatly.

Parameters:
rows - the number of buffered rows

setMessageBuffer

public static void setMessageBuffer(boolean mode)
Sets the message-buffer to store messages or to discard them after logging.

Parameters:
mode - the mode
See Also:
STORE_MESSAGES, DISCARD_MESSAGES

setOnError

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

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

getMessageBuffer

public static java.lang.String[] getMessageBuffer()
Returns the current message-buffer as String-array. This is only useful when messages are being stored.

Returns:
the current message-buffer

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.

Returns:
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,
                       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

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.