org.peace_tools.generic
Class ProgrammerLog

java.lang.Object
  extended by org.peace_tools.generic.Log
      extended by org.peace_tools.generic.ProgrammerLog

public class ProgrammerLog
extends Log

Top-level logging class for creating programmer logs.

The ProgrammerLog provides a convenient mechanism the GUI system to log relevant information to help programmers debug and troubleshoot problems. This log is essentially used to record information that may be useful for a programmer but not useful for the user.

This class is a centralized class for merely recording the logs (and not viewing/seeing) the logs. The logs are viewed/shown by the Programmer LogPane which constitutes the "View" as in the Model- View-Controller (MVC) pattern. This class represents the "Model" in the MVC pattern while the top-level frame that contains the ProgrammerLogPane serves as the controller.

Since the ProgrammerLog serves as an centralized location for cutting logs relevant/useful to the programmer, there is only one unique instance of this class in the GUI system. In order to enforce this property, this class has been designed as a Singleton pattern -- that is, this class cannot be directly instantiated. Instead the getLog() static method must be used to refer to the globally unique instance of this class. On the other the convenient, static log() method can be used to directly cut log entries.

Note:Logs for user (that would be pertinent for the user to view and take action) must be generated in the UserLog.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.peace_tools.generic.Log
Log.LogLevel
 
Field Summary
private  java.lang.StringBuffer logEntries
          This instance variable holds all the user logs that have been generated thus far via the log() method in this class.
private static ProgrammerLog programmerLog
          The globally unique instance of the UserLog.
 
Fields inherited from class org.peace_tools.generic.Log
currentLogLevel, listeners, logFile, logFileName
 
Constructor Summary
private ProgrammerLog()
          The default (and only) constructor.
 
Method Summary
static ProgrammerLog getLog()
          Obtain reference to the globally unique instance of the ProgrammerLog.
 java.lang.StringBuffer getLogEntries()
          Obtain the set of log entries contained in the user logs.
static boolean log(java.lang.Exception e)
          This method logs the specified message in the programmer log.
static boolean log(java.lang.String text)
          This method logs the specified message in the programmer log.
 
Methods inherited from class org.peace_tools.generic.Log
addLogListener, clearLog, decode, encode, getFileName, getLevel, isWritingLogs, notifyViews, parseLevel, removeLogListener, setFileName, setLevel, toggleLogWriting
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logEntries

private java.lang.StringBuffer logEntries
This instance variable holds all the user logs that have been generated thus far via the log() method in this class. The entries added are displayed by various UserLogPane classes. The entries are stored in a compact fashion to minimize the in-memory size. The UserLogPane class uses a suitable renderer to appropriately display the log entries.


programmerLog

private static final ProgrammerLog programmerLog
The globally unique instance of the UserLog. This singleton instance is used to generate and store all of the user logs displayed by the various UserLogPane objects in various windows.

Constructor Detail

ProgrammerLog

private ProgrammerLog()
The default (and only) constructor. The UserLog represents a centralized facility for cutting logs relevant/useful to the user. In other words, there must be only one, globally unique instance of this class that contains all the user logs in one centralized location. In order to ensure that only one unique instance is ever created, the constructor has been made private and a globally unique static variable is used to hold a singleton reference. The reference object can be accessed via the getLog() method.

Method Detail

getLog

public static ProgrammerLog getLog()
Obtain reference to the globally unique instance of the ProgrammerLog. This method must be used to obtain a reference to the globally unique instance of the UserLog. There is only one singleton instance of the ProgrammerLog that must be used to generate all programmer-log entries.

Returns:
The globally unique instance of the UserLog.

log

public static boolean log(java.lang.String text)
This method logs the specified message in the programmer log. After the log

Parameters:
text - The text or actual log message.
Returns:
Logs the message and returns true.

log

public static boolean log(java.lang.Exception e)
This method logs the specified message in the programmer log. After the log

Parameters:
e - Logs the exception in the programmer log.
Returns:
Logs the message and returns true.

getLogEntries

public java.lang.StringBuffer getLogEntries()
Obtain the set of log entries contained in the user logs.

Returns:
The current set of log entries contained in this class.