com.faa.flyfaa
Class FlyLog

java.lang.Object
  |
  +--com.faa.flyfaa.FlyLog

public class FlyLog
extends java.lang.Object

Class used for writing log messages.


Field Summary
private static int ConnectionTimeout
          The amount of time to wait for a connection from the cache before telling the user that the system is busy.
(package private) static int DebugLevel
          The debug level currently in force (from the properties file).
static java.lang.String DEBUGLEVEL
          Constant defining a medium level of logging (exceptions and debug statements)
static java.lang.String ERRORLEVEL
          Constant defining lowest level of logging (exceptions only)
private static java.util.Properties FLYProps
          The Properties object to hold the items in the properties file
(package private) static boolean LogEnabled
          The property indicating whether or not any logging should occur
(package private) static java.lang.String LogFile
          The path/filename to the file to be used for logging.
private static java.io.PrintWriter out
          PrintWriter for generating output
static java.lang.String PROPERTIES
          Location of the Fly-FAA properties file (also set explicitly in FlyFAAPoolServlet.init)
static java.lang.String VERBOSELEVEL
          Constant defining the highest level of logging (exceptions, debug statements, anything)
 
Constructor Summary
FlyLog()
          FlyLog constructor method.
 
Method Summary
 int getConnectionTimeout()
          Gets the property indicating the amount of time (in whole seconds) to wait for a Connection from the cache.
 int getDebugLevel()
          Gets the current debug level.
 boolean getLogEnabled()
          Gets the flag indicating whether or not logging is enabled.
 java.lang.String getLogFile()
          Gets the filename of the log file.
static void loadLogFile(java.lang.String theFile)
          Opens a possibly pre-existing, non-empty file for logging.
static void loadNewLogFile(java.lang.String theFile)
          Opens an empty file for logging.
static void out(int lvl, java.lang.String logfile, java.lang.String msg)
          Writes a message at a DebugLevel specified by lvl to the log file.
static void out(int lvl, java.lang.String logfile, java.lang.Throwable e, java.lang.String msg)
          Writes a message at a DebugLevel specified by lvl with an Exception to the log file.
static void out(java.lang.String logfile, java.lang.String msg)
          Writes a DEBUGLEVEL message to the log file.
static void out(java.lang.String logfile, java.lang.Throwable e, java.lang.String msg)
          Writes a DEBUGLEVEL message with an Exception to the log file.
static void outSpecial(java.lang.String logfile, java.lang.String msg)
          Writes a special message (with "[*NOTE]" at the beginning of it) to a log file.
 void setConnectionTimeout(int to)
          Sets the property indicating the amount of time (in whole seconds) to wait for a Connection from the cache.
 void setDebugLevel(int level)
          Sets the current debug level.
 void setLogEnabled(boolean flag)
          Sets the flag indicating whether or not logging shall be enabled.
 void setLogFile(java.lang.String name)
          Sets the log's filename.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

PROPERTIES

public static final java.lang.String PROPERTIES
Location of the Fly-FAA properties file (also set explicitly in FlyFAAPoolServlet.init)

FLYProps

private static java.util.Properties FLYProps
The Properties object to hold the items in the properties file

ERRORLEVEL

public static final java.lang.String ERRORLEVEL
Constant defining lowest level of logging (exceptions only)

DEBUGLEVEL

public static final java.lang.String DEBUGLEVEL
Constant defining a medium level of logging (exceptions and debug statements)

VERBOSELEVEL

public static final java.lang.String VERBOSELEVEL
Constant defining the highest level of logging (exceptions, debug statements, anything)

LogFile

static java.lang.String LogFile
The path/filename to the file to be used for logging.

LogEnabled

static boolean LogEnabled
The property indicating whether or not any logging should occur

DebugLevel

static int DebugLevel
The debug level currently in force (from the properties file). 1=log only exceptions. 2=log exceptions and debug statements, 3=log exceptions, debug statements, and anything else.

ConnectionTimeout

private static int ConnectionTimeout
The amount of time to wait for a connection from the cache before telling the user that the system is busy. (Not implemented.)

out

private static java.io.PrintWriter out
PrintWriter for generating output
Constructor Detail

FlyLog

public FlyLog()
       throws javax.servlet.ServletException
FlyLog constructor method. The name of the actual log file is formed by concatenating three strings. The first string is a substring consisting of all characters from the flyfaalogfile property from the properties file up to the last period ("."). The second string is a DateTimeInstance of the form yyyy_MMMddHHmm, and the third string is the remaining characters at the end of the flyfaalogfile property string (assumed to be ".txt"). If no period exists in the flyfaalogfile property, a ServletException is thrown.

Throws:
javax.servlet.ServletException - if the properties file cannot be found or is unreadable.
Method Detail

getLogFile

public java.lang.String getLogFile()
Gets the filename of the log file.

Returns:
String containing the logfile's filename

setLogFile

public void setLogFile(java.lang.String name)
Sets the log's filename.

Parameters:
name - String containing the path/filename for this log file.

getLogEnabled

public boolean getLogEnabled()
Gets the flag indicating whether or not logging is enabled.

Returns:
true if logging is enabled, otherwise false

setLogEnabled

public void setLogEnabled(boolean flag)
Sets the flag indicating whether or not logging shall be enabled.

Parameters:
flag - boolean (true if logging shall be enabled, otherwise false)

getDebugLevel

public int getDebugLevel()
Gets the current debug level. Debug levels are defined as follows:
  1. Log only major & minor errors (exceptions)
  2. Log everything (exceptions and debug output)

Returns:
int - current debugLevel

setDebugLevel

public void setDebugLevel(int level)
Sets the current debug level.

Parameters:
level - int representing the current debug level to be used.
See Also:
getDebugLevel()

getConnectionTimeout

public int getConnectionTimeout()
Gets the property indicating the amount of time (in whole seconds) to wait for a Connection from the cache.

Returns:
true if logging is enabled, otherwise false

setConnectionTimeout

public void setConnectionTimeout(int to)
Sets the property indicating the amount of time (in whole seconds) to wait for a Connection from the cache.

Parameters:
to - int containing the number of seconds to wait for a Connection

loadNewLogFile

public static void loadNewLogFile(java.lang.String theFile)
Opens an empty file for logging. If unable to do so, System.err is opened instead.

Parameters:
theFile - String containing the server path/filename to the new log file

loadLogFile

public static void loadLogFile(java.lang.String theFile)
Opens a possibly pre-existing, non-empty file for logging. If unable to do so, System.err is opened instead.

Parameters:
theFile - String containing the server path/filename to the log file

out

public static void out(java.lang.String logfile,
                       java.lang.String msg)
Writes a DEBUGLEVEL message to the log file. The message is prefixed with a Date/ Timestamp of my own choosing, which includes the milliseconds (namely: "M/d/yy HH:mm:ss.SSS:'[DEBUG]' " as defined by the SimpleDateFormat class. This produces a Date/Timestamp of a form similar to '4/6/02 18:26:03.571:[DEBUG] '. The message is only written if the 'enableLog' flag from the properties file is set. This method does not specify a parameter for the debugLevel. It will only print the msg if the debugLevel is DEBUGLEVEL, that is, if all log messages are supposed to be printed.

Parameters:
logfile - String containing the server path/filename to the log file
msg - String containing the log message to be printed

out

public static void out(int lvl,
                       java.lang.String logfile,
                       java.lang.String msg)
Writes a message at a DebugLevel specified by lvl to the log file. The message is prefixed with a custom Date/Timestamp of a form similar to '9/30/02 20:26:03.389:' followed by either '[WORDY]', '[DEBUG]' or '[ERROR]' depending on the given lvl. The message is only written if the 'enableLog' flag from the properties file is set and the 'DebugLevel' property from the properties file is greater than or equal to the given lvl.

Parameters:
lvl - int representing the DebugLevel of this log message. If the DebugLevel property is at least this value, the message will be printed.
logfile - String containing the server path/filename to the log file
msg - String containing the log message to be printed

out

public static void out(java.lang.String logfile,
                       java.lang.Throwable e,
                       java.lang.String msg)
Writes a DEBUGLEVEL message with an Exception to the log file. The message is prefixed with a medium format Date/Timestamp of a form similar to '4/23/02 8:26:03 PM:'. The message is only written if the 'enableLog' flag from the properties file is set. This method does not specify a parameter for the DebugLevel. It will only print the msg if the DebugLevel is DEBUGLEVEL, that is, if all log messages are supposed to be printed.

Parameters:
logfile - String containing the server path/filename to the log file
e - Throwable object (usually an Exception)
msg - String containing the log message to be printed

out

public static void out(int lvl,
                       java.lang.String logfile,
                       java.lang.Throwable e,
                       java.lang.String msg)
Writes a message at a DebugLevel specified by lvl with an Exception to the log file. The message is prefixed with a medium format Date/Timestamp of a form similar to '4/23/02 8:26:03 PM:'. The message is only written if the 'enableLog' flag from the properties file is set and the 'DebugLevel' property from the properties file is greater than or equal to the given lvl.

Parameters:
lvl - int representing the DebugLevel of this log message.
logfile - String containing the server path/filename to the log file
e - Throwable object (usually an Exception)
msg - String containing the log message to be printed

outSpecial

public static void outSpecial(java.lang.String logfile,
                              java.lang.String msg)
Writes a special message (with "[*NOTE]" at the beginning of it) to a log file.

Parameters:
logfile - String containing the server path/filename to the log file
msg - String containing the log message to be printed