com.ptc.elog
Class Elog

java.lang.Object
  extended bycom.ptc.elog.Elog

public class Elog
extends Object


Field Summary
static String ALL
           
private static String DEFAULT_ELOG_FILE
           
private static byte[] EOL
           
(package private)  long lEOFRecord
           
private  boolean m_bFilterApp
           
private  boolean m_bFilterClass
           
private  boolean m_bFilterDate
           
private  boolean m_bFilterNode
           
private  boolean m_bFilterThread
           
private  boolean m_bFilterUser
           
private  boolean m_bFilterVerbosity
           
private  boolean m_bLoggingOn
           
private  byte[] m_buffer
           
private  Date m_date
           
private  Date m_date1
           
private  Date m_date2
           
private  long m_lEOF
           
private  long m_lTime
           
private  int m_nRVerbosity
           
private  int m_nVerbosity
           
private  int m_nWVerbosity
           
private  RandomAccessFile m_raf
           
private  ElogRecord m_record
           
private  ElogRecord[] m_records
           
private  StringBuffer m_sbuffer
           
private  String m_strApp
           
private  String[] m_strApps
           
private  String m_strClass
           
private  String[] m_strClasses
           
private  String m_strFile
           
private  String m_strLine
           
private  String m_strMsg
           
private  String m_strNode
           
private  String[] m_strNodes
           
private  String m_strThread
           
private  String[] m_strThreads
           
private  String m_strUser
           
private  String[] m_strUsers
           
static int MAX_LAST_ROWS
           
static String MULTIPLE
           
private static String PAD
           
(package private)  ElogRecord record
           
private static String[] STAT
           
static String[] STATUS
           
(package private)  String strClass
           
private static String UNKNOWN
           
static int V_DEBUG
           
static int V_DUMP
           
static int V_ERROR
           
static int V_INFO
           
private static int V_OFFSET
           
static int V_WARN
           
(package private)  Vector vClasses
           
 
Constructor Summary
Elog()
          This is just to prevent it's being used by apps.
Elog(Object obj, String s)
          Constructor
Elog(Object obj, String s, int v)
          Constructor
 
Method Summary
 void close(Object obj)
          This method closes the Elog.
private  ElogRecord filterRecord(ElogRecord record)
          This method tests whether the an ElogRecord passes each filter.
 String[] getFilterApps()
          This method returns the String[] array of app values that determine whether an ElogRecord is read.
 String[] getFilterClasses()
          This method returns the String[] array of class values that determine whether an ElogRecord is read.
 Date[] getFilterDates()
          This method returns the current low/high date/time values for filtering Elog reads.
 String[] getFilterNodes()
          This method returns the String[] array of Node values that determine whether an ElogRecord is read.
 String[] getFilterThreads()
          This method returns the String[] array of thread values that determine whether an ElogRecord is read.
 String[] getFilterUsers()
          This method returns the String[] array of User values that determine whether an ElogRecord is read.
 int getFilterVerbosity()
          This method returns the current Read verbosity.
 String[] getUniqueAppsFromElog(long lMaxRead, int nMaxGet)
          This method returns the String[] array of unique App values currently in the Elog.
 String[] getUniqueClassesFromElog(long lMaxRead, int nMaxGet)
          This method returns the String[] array of unique Class values currently in the Elog.
 String[] getUniqueNodesFromElog(long lMaxRead, int nMaxGet)
          This method returns the String[] array of unique Node values currently in the Elog.
 String[] getUniqueThreadsFromElog(long lMaxRead, int nMaxGet)
          This method returns the String[] array of unique Thread values currently in the Elog.
 String[] getUniqueUsersFromElog(long lMaxRead, int nMaxGet)
          This method returns the String[] array of unique User values currently in the Elog.
 int getWriteVerbosity()
          This method gets the application's current write verbosity.
private  void init(Object obj)
          This private method is shared by the real constructors
private  boolean isValidApp(ElogRecord record)
          This method tests whether the app in an ElogRecord is within the app Filter range.
private  boolean isValidClass(ElogRecord record)
          This method tests whether the Class in an ElogRecord is within the Class Filter range.
private  boolean isValidDate(ElogRecord record)
          This method tests whether the date/time in an ElogRecord is within the Date Filter range.
private  boolean isValidNode(ElogRecord record)
          This method tests whether the Node in an ElogRecord is within the Node Filter range.
private  boolean isValidThread(ElogRecord record)
          This method tests whether the thread in an ElogRecord is within the thread Filter range.
private  boolean isValidUser(ElogRecord record)
          This method tests whether the User in an ElogRecord is within the User Filter range.
private  boolean isValidVerbosity(ElogRecord record)
          This method tests whether the Verbosity in an ElogRecord is equal to or less than the Read Verbosity filter value.
 String read(long lRecord)
          This method reads an Elog record and returns it as a String.
 ElogRecord[] readLastRecords(long lCount)
          This method reads the last N-records in the Elog and returns an array of ElogRecords.
 ElogRecord readRecord(long lRecord)
          Reads an Elog record and returns a parsed ElogRecord.
 void setFilterApps(String[] s)
          This method sets the App values that an ElogRecord must have to allow an Elog read.
 void setFilterAppsEnabled(boolean b)
          This method turns on/off the filtering by application of Elog reads.
 void setFilterClasses(String[] s)
          This method sets the Class values that an ElogRecord must have to allow an Elog read.
 void setFilterClassesEnabled(boolean b)
          This method turns on/off the filtering by classes of Elog reads.
 void setFilterDates(Date d1, Date d2)
          This method sets the low/high date/time values for filtering Elog reads.
 void setFilterDates(int d)
          This method indirectly sets the low/high Date filters.
 void setFilterDatesEnabled(boolean b)
          This method turns on/off the filtering by dates of Elog reads.
 void setFilterNodes(String[] s)
          This method sets the Node values that an ElogRecord must have to allow an Elog read.
 void setFilterNodesEnabled(boolean b)
          This method turns on/off the filtering by Nodes of Elog reads.
 void setFilterThreads(String[] s)
          This method sets the thread values that an ElogRecord must have to allow an Elog read.
 void setFilterThreadsEnabled(boolean b)
          This method turns on/off the filtering by threads of Elog reads.
 void setFilterUsers(String[] s)
          This method sets the User values that an ElogRecord must have to allow an Elog read.
 void setFilterUsersEnabled(boolean b)
          This method turns on/off the filtering by users of Elog reads.
 void setFilterVerbosity(int n)
          This method sets the highest Verbosity value that an ElogRecord may have to allow an Elog read.
 void setFilterVerbosityEnabled(boolean b)
          This method turns on/off the filtering by verbosity of Elog reads.
 void setLoggingEnabled(boolean b)
          This method controls whether an application writes to the Elog.
 void setWriteVerbosity(int n)
          This method sets an application's verbosity for writing to the Elog.
private  String toSize(String s, int n)
          This method forces a string to a set size, blankpadding right as needed.
 void write(Object obj, int nVerbosity, String strMsg)
          This writes an Elog record.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_ELOG_FILE

private static final String DEFAULT_ELOG_FILE
See Also:
Constant Field Values

UNKNOWN

private static final String UNKNOWN
See Also:
Constant Field Values

PAD

private static final String PAD
See Also:
Constant Field Values

EOL

private static final byte[] EOL

STAT

private static final String[] STAT

V_OFFSET

private static final int V_OFFSET
See Also:
Constant Field Values

V_DUMP

public static final int V_DUMP
See Also:
Constant Field Values

V_DEBUG

public static final int V_DEBUG
See Also:
Constant Field Values

V_INFO

public static final int V_INFO
See Also:
Constant Field Values

V_WARN

public static final int V_WARN
See Also:
Constant Field Values

V_ERROR

public static final int V_ERROR
See Also:
Constant Field Values

STATUS

public static final String[] STATUS

MAX_LAST_ROWS

public static final int MAX_LAST_ROWS
See Also:
Constant Field Values

ALL

public static final String ALL
See Also:
Constant Field Values

MULTIPLE

public static final String MULTIPLE
See Also:
Constant Field Values

m_strFile

private String m_strFile

m_raf

private RandomAccessFile m_raf

m_record

private ElogRecord m_record

m_buffer

private byte[] m_buffer

m_sbuffer

private StringBuffer m_sbuffer

m_strLine

private String m_strLine

m_strUser

private String m_strUser

m_strNode

private String m_strNode

m_strApp

private String m_strApp

m_records

private ElogRecord[] m_records

m_lEOF

private long m_lEOF

m_date

private Date m_date

m_strThread

private String m_strThread

m_strClass

private String m_strClass

m_nVerbosity

private int m_nVerbosity

m_strMsg

private String m_strMsg

m_nWVerbosity

private int m_nWVerbosity

m_nRVerbosity

private int m_nRVerbosity

m_date1

private Date m_date1

m_date2

private Date m_date2

m_lTime

private long m_lTime

m_strNodes

private String[] m_strNodes

m_strApps

private String[] m_strApps

m_strThreads

private String[] m_strThreads

m_strUsers

private String[] m_strUsers

m_strClasses

private String[] m_strClasses

m_bFilterDate

private boolean m_bFilterDate

m_bFilterNode

private boolean m_bFilterNode

m_bFilterApp

private boolean m_bFilterApp

m_bFilterThread

private boolean m_bFilterThread

m_bFilterUser

private boolean m_bFilterUser

m_bFilterClass

private boolean m_bFilterClass

m_bFilterVerbosity

private boolean m_bFilterVerbosity

m_bLoggingOn

private boolean m_bLoggingOn

vClasses

Vector vClasses

record

ElogRecord record

strClass

String strClass

lEOFRecord

long lEOFRecord
Constructor Detail

Elog

public Elog()
This is just to prevent it's being used by apps.

Since:
19 May, 1999.

Elog

public Elog(Object obj,
            String s,
            int v)
Constructor

Parameters:
obj - - Is used to ID the Application that is creating the Elog.
s - - The name of the Elog file. If null or empty, it defaults to "elog.txt"
v - - The write verbosity. Must be V_INFO, V_DEBUG, or V_DUMP.
Since:
19 May, 1999

Elog

public Elog(Object obj,
            String s)
Constructor

Parameters:
obj - - Is used to ID the Application that is creating the Elog.
s - - The name of the Elog file. If null or empty, it defaults to "elog.txt"
Since:
19 May, 1999
Method Detail

init

private void init(Object obj)
This private method is shared by the real constructors

Parameters:
obj - - The Application object
Returns:
nothing
Since:
19 May 1999

close

public void close(Object obj)
This method closes the Elog.

Parameters:
obj - - This object is what Elog uses to ID the calling class.
Returns:
nothing
Since:
19 May 1999

write

public void write(Object obj,
                  int nVerbosity,
                  String strMsg)
This writes an Elog record.

Parameters:
obj - This Object is what Elog uses to ID the calling class.
nVerbosity - This int is what Elog uses to determine the Verbosity of what is written to the Elog.
strMsg - This String is the message the user writes to the Elog.
Returns:
nothing
Since:
19 May, 1999

read

public String read(long lRecord)
This method reads an Elog record and returns it as a String. Returns null if the Elog is totally empty. Returns null if the requested record is beyond the end of the Elog. Returns null if there is an I/O error.

Parameters:
lRecord - This long is the Elog record number to read. It is 1-based. If a negative number is entered, the method returns the final record in the Elog. If a number beyond the end of Elog is entered, the method returns a null.
Returns:
A String that is the Elog record, or null.
Since:
19 May, 1999

readRecord

public ElogRecord readRecord(long lRecord)
Reads an Elog record and returns a parsed ElogRecord. It is 1-based. If a negative number is entered, the method returns the final record in the Elog. If a number beyond the end of Elog is entered, the method returns a null. If there is an I/O error, returns null;

Parameters:
lRecord - This long is the Elog record number to read.
Returns:
A parsed ElogRecord, or null.
Since:
19 May, 1999

readLastRecords

public ElogRecord[] readLastRecords(long lCount)
This method reads the last N-records in the Elog and returns an array of ElogRecords. Returns null if the Elog is empty or no Elog records passed filtering. Returns null on an I/O error. The non-null array is always MAX_LAST_ROWS long. Elements in the array may be null. Records are loaded into the array from top to bottom. The first null marks the end of the non-null elements.

Parameters:
lCount - This long is the number of records to read.
Returns:
An array of ElogRecords, or null.
Since:
19 May, 1999

setLoggingEnabled

public void setLoggingEnabled(boolean b)
This method controls whether an application writes to the Elog. It applies to the entire application.

Parameters:
b - This boolean turns Elog writing on/off.
Returns:
nothing
Since:
19 May, 1999

setWriteVerbosity

public void setWriteVerbosity(int n)
This method sets an application's verbosity for writing to the Elog. Info, Warnings, and Errors are always written to the Elog, unless Elog writing is totally turned off. So this method really just controls whether the additional Verbosities: Debug and All are written to the Elog.

Parameters:
n - This int is either V_INFO, V_DEBUG, V_DUMP. It controls the write verbosity.
Returns:
nothing
Since:
19 May, 1999

getWriteVerbosity

public int getWriteVerbosity()
This method gets the application's current write verbosity.

Returns:
The application's current write verbosity: V_INFO, V_DEBUG, or V_DUMP.
Since:
19 May, 1999

setFilterDatesEnabled

public void setFilterDatesEnabled(boolean b)
This method turns on/off the filtering by dates of Elog reads.

Parameters:
b - Boolean turns elog date filtering on/off.
Returns:
none
Since:
19 May, 1999

setFilterDates

public void setFilterDates(Date d1,
                           Date d2)
This method sets the low/high date/time values for filtering Elog reads. Passing in nulls, or dates in the wrong order has no effect.

Parameters:
d1 - This Date is the lowest date/time value that Elog will read.
d2 - This Date is the highest date/time that Elog will read.
Returns:
none
Since:
19 May, 1999

setFilterDates

public void setFilterDates(int d)
This method indirectly sets the low/high Date filters. It accepts a Time Delta in seconds and tells isValidDate to use this value to recalculate the low/high values each time isValidDate is called. Passing in a negative or zero value has no effect.

Parameters:
d - This is the number of seconds delta.
Returns:
none
Since:
20 May, 1999

getFilterDates

public Date[] getFilterDates()
This method returns the current low/high date/time values for filtering Elog reads. If none are set, it returns an array of two null Dates. If Date filtering is set to false, it still returns the Date values that would be used if date filtering were turned on.

Returns:
An array of two Dates: lowest, highest.
Since:
19 May, 1999

isValidDate

private boolean isValidDate(ElogRecord record)
This method tests whether the date/time in an ElogRecord is within the Date Filter range. It returns true of the date/time is equal to either the low value or high value, or is between the values.

Parameters:
record - This ElogRecord is the record that is being tested.
Returns:
True or false.
Since:
19 May, 1999

setFilterNodesEnabled

public void setFilterNodesEnabled(boolean b)
This method turns on/off the filtering by Nodes of Elog reads.

Parameters:
b - Boolean turns elog Node filtering on/off.
Returns:
none
Since:
19 May, 1999

setFilterNodes

public void setFilterNodes(String[] s)
This method sets the Node values that an ElogRecord must have to allow an Elog read. The String[] array passed in normally contains no null elements. The method ignores any elements after the first null.

Parameters:
s - This String[] is the array of Node values that ElogRecord is tested against.
Since:
19 May, 1999

getFilterNodes

public String[] getFilterNodes()
This method returns the String[] array of Node values that determine whether an ElogRecord is read. The source is the filter, not the Elog.

Returns:
The String[] array of Node values that determine whether an ElogRecord is read.
Since:
19 May, 1999

getUniqueNodesFromElog

public String[] getUniqueNodesFromElog(long lMaxRead,
                                       int nMaxGet)
This method returns the String[] array of unique Node values currently in the Elog. It reads backwards from the end of Elog.

Parameters:
lMaxRead - This is the maximum number of Elog records to read.
nMaxGet - This is the maximum number of unique values to return.
Returns:
The String[] array of Node values that determine whether an ElogRecord is read.
Since:
19 May, 1999

isValidNode

private boolean isValidNode(ElogRecord record)
This method tests whether the Node in an ElogRecord is within the Node Filter range. Returns true if Node filtering is turned off. Returns true if Node filter set is null or empty. Trims whitespace from Node value in ElogRecord and value in Elog before test.

Parameters:
record - This ElogRecord is the record that is being tested.
Returns:
True or false
Since:
19 May, 1999

setFilterAppsEnabled

public void setFilterAppsEnabled(boolean b)
This method turns on/off the filtering by application of Elog reads.

Parameters:
b - Boolean turns elog app filtering on/off.
Returns:
none
Since:
19 May, 1999

setFilterApps

public void setFilterApps(String[] s)
This method sets the App values that an ElogRecord must have to allow an Elog read. The String[] array passed in normally contains no null elements. The method ignores any elements after the first null.

Parameters:
s - This String[] is the array of app values that ElogRecord is tested against.
Returns:
none
Since:
19 May, 1999

getFilterApps

public String[] getFilterApps()
This method returns the String[] array of app values that determine whether an ElogRecord is read.

Returns:
The String[] array of app values that determine whether an ElogRecord is read.
Since:
19 May, 1999

getUniqueAppsFromElog

public String[] getUniqueAppsFromElog(long lMaxRead,
                                      int nMaxGet)
This method returns the String[] array of unique App values currently in the Elog. It reads backwards from the end of Elog.

Parameters:
lMaxRead - This is the maximum number of Elog records to read.
nMaxGet - This is the maximum number of unique values to return.
Returns:
The String[] array of App values that determine whether an ElogRecord is read.
Since:
19 May, 1999

isValidApp

private boolean isValidApp(ElogRecord record)
This method tests whether the app in an ElogRecord is within the app Filter range. Returns true if app filtering is turned off. Returns true if app filter set is null or empty. Trims whitespace from app value in ElogRecord and value in Elog before test.

Parameters:
record - This is the ElogRecord being tested.
Returns:
True or false
Since:
19 May, 1999

setFilterThreadsEnabled

public void setFilterThreadsEnabled(boolean b)
This method turns on/off the filtering by threads of Elog reads.

Parameters:
b - Boolean turns elog thread filtering on/off.
Returns:
none
Since:
19 May, 1999

setFilterThreads

public void setFilterThreads(String[] s)
This method sets the thread values that an ElogRecord must have to allow an Elog read.

Parameters:
s - This String[] is the array of thread values that ElogRecord is tested against.
Since:
19 May, 1999

getFilterThreads

public String[] getFilterThreads()
This method returns the String[] array of thread values that determine whether an ElogRecord is read.

Returns:
The String[] array of thread values that determine whether an ElogRecord is read.
Since:
19 May, 1999

getUniqueThreadsFromElog

public String[] getUniqueThreadsFromElog(long lMaxRead,
                                         int nMaxGet)
This method returns the String[] array of unique Thread values currently in the Elog. It reads backwards from the end of Elog.

Parameters:
lMaxRead - This is the maximum number of Elog records to read.
nMaxGet - This is the maximum number of unique values to return.
Returns:
The String[] array of Thread values that determine whether an ElogRecord is read.
Since:
19 May, 1999

isValidThread

private boolean isValidThread(ElogRecord record)
This method tests whether the thread in an ElogRecord is within the thread Filter range. Returns true if thread filtering is turned off. Returns true if thread filter set is null or empty. Trims whitespace from thread value in ElogRecord and value in Elog before test.

Parameters:
record - ElogRecord being tested.
Returns:
True or false.
Since:
19 May, 1999

setFilterUsersEnabled

public void setFilterUsersEnabled(boolean b)
This method turns on/off the filtering by users of Elog reads.

Parameters:
b - Boolean turns elog user filtering on/off.
Returns:
none
Since:
19 May, 1999

setFilterUsers

public void setFilterUsers(String[] s)
This method sets the User values that an ElogRecord must have to allow an Elog read.

Parameters:
s - This String[] is the array of Usere values that ElogRecord is tested against.
Returns:
none
Since:
19 May, 1999

getFilterUsers

public String[] getFilterUsers()
This method returns the String[] array of User values that determine whether an ElogRecord is read.

Returns:
The String[] array of User values that determine whether an ElogRecord is read.
Since:
19 May, 1999

getUniqueUsersFromElog

public String[] getUniqueUsersFromElog(long lMaxRead,
                                       int nMaxGet)
This method returns the String[] array of unique User values currently in the Elog. It reads backwards from the end of Elog.

Parameters:
lMaxRead - This is the maximum number of Elog records to read.
nMaxGet - This is the maximum number of unique values to return.
Returns:
The String[] array of User values that determine whether an ElogRecord is read.
Since:
19 May, 1999

isValidUser

private boolean isValidUser(ElogRecord record)
This method tests whether the User in an ElogRecord is within the User Filter range. Returns true if User filtering is turned off. Returns true if User filter set is null or empty. Trims whitespace from User value in ElogRecord and value in Elog before test.

Parameters:
record - ElogRecord being tested
Returns:
True or false.
Since:
19 May, 1999

setFilterClassesEnabled

public void setFilterClassesEnabled(boolean b)
This method turns on/off the filtering by classes of Elog reads.

Parameters:
b - Boolean turns elog class filtering on/off.
Returns:
none
Since:
19 May, 1999

setFilterClasses

public void setFilterClasses(String[] s)
This method sets the Class values that an ElogRecord must have to allow an Elog read.

Parameters:
s - This String[] is the array of class values that ElogRecord is tested against.
Returns:
none
Since:
19 May, 1999

getFilterClasses

public String[] getFilterClasses()
This method returns the String[] array of class values that determine whether an ElogRecord is read.

Returns:
The String[] array of Class values that determine whether an ElogRecord is read.
Since:
19 May, 1999

getUniqueClassesFromElog

public String[] getUniqueClassesFromElog(long lMaxRead,
                                         int nMaxGet)
This method returns the String[] array of unique Class values currently in the Elog. It reads backwards from the end of Elog.

Parameters:
lMaxRead - This is the maximum number of Elog records to read.
nMaxGet - This is the maximum number of unique values to return.
Returns:
The String[] array of Class values that determine whether an ElogRecord is read.
Since:
19 May, 1999

isValidClass

private boolean isValidClass(ElogRecord record)
This method tests whether the Class in an ElogRecord is within the Class Filter range. Returns true if Class filtering is turned off. Returns true if Class filter set is null or empty. Trims whitespace from Class value in ElogRecord and value in Elog before test.

Parameters:
record - ElogRecord being tested
Returns:
True or false.
Since:
19 May, 1999

setFilterVerbosityEnabled

public void setFilterVerbosityEnabled(boolean b)
This method turns on/off the filtering by verbosity of Elog reads.

Parameters:
b - Boolean turns elog verbosity filtering on/off.
Returns:
none
Since:
19 May, 1999

setFilterVerbosity

public void setFilterVerbosity(int n)
This method sets the highest Verbosity value that an ElogRecord may have to allow an Elog read. Elog always reads V_INFO, V_WARNING, and V_ERROR records. Elog will read V_DEBUG records if the highest verbosity is set to V_DEBUG or V_DUMP. Elog will read V_DUMP records if the highest verbosity is set to V_DUMP.

Parameters:
n - This int is either V_INFO, V_DEBUG, or V_DUMP. It sets the highest verbosity Elog will read.
Since:
19 May, 1999

getFilterVerbosity

public int getFilterVerbosity()
This method returns the current Read verbosity.

Since:
19 May, 1999

isValidVerbosity

private boolean isValidVerbosity(ElogRecord record)
This method tests whether the Verbosity in an ElogRecord is equal to or less than the Read Verbosity filter value. Returns true if verbosity filtering is turned off.

Parameters:
record - ElogRecord being tested.
Returns:
True for False.
Since:
19 May, 1999

filterRecord

private ElogRecord filterRecord(ElogRecord record)
This method tests whether the an ElogRecord passes each filter. Returns null if record is null.

Parameters:
record - ElogRecord being tested.
Returns:
True for False.
Since:
19 May, 1999

toSize

private String toSize(String s,
                      int n)
This method forces a string to a set size, blankpadding right as needed.

Parameters:
s - String to be adjusted.
n - Length to which that string is to be set.
Returns:
String of the specified length.
Since:
19 May, 1999