org.jogre.common.util
Class JogreLogger

java.lang.Object
  extended byorg.jogre.common.util.JogreLogger
All Implemented Interfaces:
IJogreLog

public class JogreLogger
extends Object
implements IJogreLog

Custom logging was created for JOGRE so that is as flexible and as lightweight as possible (e.g. log4j is too large at 345kb). This logging stores a timestamp, followed by the class and then the message itself.

To use this class you simply create a new instance at the top of a class such as:

JogreLogger logger = new JogreLog (this.getClass());

To use this class in source code use the log (String message), error (String method, String message), info (String method, String message) and debug (String method, String message) methods. The error method should be used when there is simply an error (used for speed), logInfo for logging information (on a stable system) and logDebug (slower) for debugging an application (logs everything).

To see the priority of debug output at run time by setting the following key/value properties in a "game.properties" file. All of these properties are optional and if they don't exist then their default values are assumed (which are in bold).

Logs which are saved by file are saved in the following location - "logs/yyyy_MM/log_dd_MMM_yyyy.txt" where y = year, d = day and M = month e.g. "logs/2004_04/log_29_April_2004.txt". This logger is not anywhere near as efficient as others but this will be investigated soon.

Version:
Alpha 0.2.1
Author:
Bob Marks

Field Summary
protected  String className
          Name of this class.
protected  int consolePriority
          Priority of console logging.
protected  int filePriority
          Priority of file logging.
protected  boolean showPriority
          If this is true then show the priority of the log as a String.
 
Fields inherited from interface org.jogre.common.util.IJogreLog
DEBUG, DEFAULT_CONSOLE_PRIORITY, DEFAULT_FILE_PRIORITY, DEFAULT_SHOW_PRIORITY, ERROR, INFO, NONE, PRIORITY_STRS
 
Constructor Summary
JogreLogger(Class loggedClass)
          Constructor which takes the class of the logged Class.
 
Method Summary
 void debug(String method, String message)
          Log a debug message.
 void error(String method, String message)
          Log an error message.
 void info(String method, String message)
          Log an information message.
 void log(String message)
          Simple log which will go in at INFO level.
 void stacktrace(Exception e)
          Logs a stacktrace.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

className

protected String className
Name of this class.


consolePriority

protected int consolePriority
Priority of console logging.


filePriority

protected int filePriority
Priority of file logging.


showPriority

protected boolean showPriority
If this is true then show the priority of the log as a String.

Constructor Detail

JogreLogger

public JogreLogger(Class loggedClass)
Constructor which takes the class of the logged Class.

Parameters:
loggedClass -
Method Detail

error

public void error(String method,
                  String message)
Log an error message.

Parameters:
method - Method in a class.
message - Message to log.

info

public void info(String method,
                 String message)
Log an information message.

Parameters:
method - Method in a class.
message - Message to log.

debug

public void debug(String method,
                  String message)
Log a debug message.

Parameters:
method - Method in a class.
message - Message to log.

log

public void log(String message)
Simple log which will go in at INFO level.

Parameters:
message - Message to log

stacktrace

public void stacktrace(Exception e)
Logs a stacktrace.

Parameters:
e - Exception object.