org.peace_tools.generic
Class UserLog

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

public class UserLog
extends Log

Top-level logging class for creating user logs.

The UserLog provides a convenient mechanism the GUI system to log relevant information at various levels of severity. This log is essentially used to provide the user with useful information. Note that this class is a centralized class for merely recording the logs (and not viewing/seeing) the logs. The logs are viewed/shown by the UserLogPane 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 UserLogPane serves as the controller.

Since the UserLog serves as an centralized location for cutting logs relevant/useful to the user, 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 programming aids and debugging (that would be pertinent for a programmer to view and understand) must be generated in the free form ProgrammerLog and not in the UserLog.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.peace_tools.generic.Log
Log.LogLevel
 
Field Summary
private  javax.swing.table.DefaultTableModel logEntries
          This instance variable holds all the user logs that have been generated thus far via the log() method in this class.
private static UserLog userLog
          The globally unique instance of the UserLog.
 
Fields inherited from class org.peace_tools.generic.Log
currentLogLevel, listeners, logFile, logFileName
 
Constructor Summary
private UserLog()
          The default (and only) constructor.
 
Method Summary
static UserLog getLog()
          Obtain reference to the globally unique instance of the UserLog.
 javax.swing.table.DefaultTableModel getLogEntries()
          Obtain the set of log entries contained in the user logs.
static boolean log(Log.LogLevel level, java.lang.String component, java.lang.String text)
          This method logs the specified message at the given level.
 
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 javax.swing.table.DefaultTableModel 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.


userLog

private static final UserLog userLog
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

UserLog

private UserLog()
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 UserLog getLog()
Obtain reference to the globally unique instance of the UserLog. 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 UserLog that must be used to generate all user-log entries.

Returns:
The globally unique instance of the UserLog.

log

public static boolean log(Log.LogLevel level,
                          java.lang.String component,
                          java.lang.String text)
This method logs the specified message at the given level. If the level is valid (higher than the current setting) then the message is logged and true returned. Otherwise, false is returned.

Parameters:
level - The level of the log to be cut.
component - The component or subsystem that is generating the log message.
text - The text or actual log message.
Returns:
True if logged, false otherwise

getLogEntries

public javax.swing.table.DefaultTableModel getLogEntries()
Obtain the set of log entries contained in the user logs.

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