|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.lang.Thread | +--vc.util.Logger
Title: Logger Description: Logger is a simple class that can offer many features of logging in a very powerfull manner. This class offers the logging features are provided in a userfriendly manner. The features are provided by this class are sufficient for most of the project requirements and it can be extended for more feture. It's features include : 1. Cache the log messages and write the log using a background thread 2. Frequency of the log writing can be set based upon requirements 3. Logging to multiple I/O devices is supported including Console, files and other type of streams 4. Abstraction for logging the Exceptions, different levels of logging, timestamps, different formats of logging etc. For using the class instantiate it with the required parameters and access its methods.
Field Summary | |
static int |
DebugLevel_High
This flag/constant is to be used for setting the debug level on. |
static int |
DebugLevel_Highest
This flag/constant is to be used for setting the debug level on. |
static int |
DebugLevel_Low
This flag/constant is to be used for setting the debug level on. |
static int |
DebugLevel_Lowest
This flag/constant is to be used for setting the debug level on. |
static int |
DebugLevel_Medium
This flag/constant is to be used for setting the debug level on. |
static int |
DebugLevel_Off
This flag/constant is to be used for setting the debugging to off. |
static int |
ExceptionLogLevel_OriginOnly
This flag/constant is to be used if the Exception message is to be logged with the information that an exception of a particular type was raised. |
static int |
ExceptionLogLevel_WithMessage
This flag/constant is to be used if the Exception message is to be logged with the detailed information. |
static int |
ExceptionLogLevel_WithStackTrace
This flag/constant is to be used if the Exception message is to be logged with the detailed information and stacktrace will be logged into the I/O devices like console and streams. |
static int |
LogFormat_MsgTypeFirst
This flag/constant is to be used if the log entries should be made in a format as |
static int |
LogFormat_TimeStampFirst
This flag/constant is to be used if the log entries should be made in a format as |
static int |
LoggingFrequency_High
This flag/constant is to be used if the logging activity is very high in a particular application. |
static int |
LoggingFrequency_Low
This flag/constant is to be used if the logging activity is not very high in a particular application. |
static int |
LoggingFrequency_Medium
This flag/constant is to be used if the logging activity is neigther very high nor very low in a particular application. |
static int |
LoggingType_CacheAndLog
This flag/constant is to be used if messages are to be cached/queued and then logged by using abackground thread. |
static int |
LoggingType_LogImmediatly
This flag/constant is to be used if messages are to be logged immediatly without queuing. |
static int |
MsgType_Critical
This flag/constant is to be used if the log message is a Critical Error |
static int |
MsgType_Error
This flag/constant is to be used if the log message is an Error |
static int |
MsgType_Exception
This flag/constant is to be used if the log message is an Exception Information |
static int |
MsgType_Info
This flag/constant is to be used if the log message is an Information |
static int |
MsgType_UserDef
This flag/constant is to be used if the log message is user-defined/non-standard |
static int |
MsgType_Warning
This flag/constant is to be used if the log message is a Warning |
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
Logger(int loggingType)
Logger() - This constructor is to be used for constructing the object which dont log the messages to a file(atleast initially). |
|
Logger(java.lang.String logFileName,
int loggingType,
int loggingFrequency)
Logger() - This constructor is to be used for constructing the object which will log the messages to a file in addition to other I/O devices like Console. |
Method Summary | |
void |
addExtraLogDevice(java.io.OutputStream logStream)
Adds OutputStream object to the list of existing log devices. |
void |
addExtraLogDevice(java.io.Writer logWriter)
Adds LogWriter object to the list of existing log devices. |
void |
finalize()
This method does the clenup for the object before it dies. |
boolean |
getConsoleLogging()
Returns the current console logging status of the Logger object. |
int |
getDebugLevel()
Returns the current debugging level of the Logger object. |
java.io.FileOutputStream |
getLogFile()
Returns the default log file associated with the Logger object |
int |
getLogFormat()
Returns the current logging format of this object |
void |
logDebugMessage(int debugLevel,
java.lang.String message)
Synchronized method logDebugMessage() - Writes the debug messages to the log devices eigther by queueing the message or writing it directly to the log devices, based upon the looggingType parameter passed to the constructor of the object. |
void |
logException(IgnorableException iex,
java.lang.String source)
Synchronized method logException() - Writes the exception inmformation to the log devices eigther by queueing the message or writing it directly to the log devices, based upon the looggingType parameter passed to the constructor of the object. |
void |
logException(java.lang.Throwable catchedException,
int exceptionLogLevel)
Synchronized method logException() - Writes the exception inmformation to the log devices eigther by queueing the message or writing it directly to the log devices, based upon the looggingType parameter passed to the constructor of the object. |
void |
logException(VCException catchedException,
java.lang.String source)
Synchronized method logException() - Writes the exception inmformation to the log devices eigther by queueing the message or writing it directly to the log devices, based upon the looggingType parameter passed to the constructor of the object. |
void |
logExceptionWithMessage(java.lang.Throwable catchedException,
int exceptionLogLevel,
int messageType,
java.lang.String message,
java.lang.String customMessageTitle)
Synchronized method logExceptionWithMessage() - Writes the exception inmformation to the log devices eigther by queueing the message or writing it directly to the log devices, based upon the looggingType parameter passed to the constructor of the object. |
void |
logMessage(int messageType,
java.lang.String message,
java.lang.String customMessageTitle)
Synchronized method logMessage() - Writes the log messages to the log devices eigther by queueing the message or writing it directly to the log devices, based upon the looggingType parameter passed to the constructor of the object. |
void |
logMessageWithoutCaching(java.lang.String message)
Synchronized method logMessageWithoutCaching() - Writes the messages to the log devices directly without caching the messages in a queue. |
void |
removeAllExtraLogDevices()
This will remove all the extra log devices that existwith this object. |
void |
run()
This method is for the multithreaded functionality required by the objects of Logger. |
void |
setConsoleLogging(boolean isConsoleLog)
Console Logging can be turned on and off with this method. |
void |
setDebugLevel(int debugLevel)
sets the current debug level of the Logger object. |
void |
setLogFile(java.io.FileOutputStream logFile)
Sets/Resets the Logger object's data memeber logFile to the parameter logFile. |
void |
setLogFile(java.lang.String logFileName)
Sets/Resets the Logger object's data memeber logFile to the file named with the value of the parameter logFileName. |
void |
setLogFormat(int logFormat)
Sets the Logger object's logging format with the parameter logFormat. |
Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int LoggingType_CacheAndLog
public static final int LoggingType_LogImmediatly
public static final int LogFormat_TimeStampFirst
public static final int LogFormat_MsgTypeFirst
public static final int MsgType_UserDef
public static final int MsgType_Info
public static final int MsgType_Warning
public static final int MsgType_Error
public static final int MsgType_Critical
public static final int MsgType_Exception
public static final int ExceptionLogLevel_OriginOnly
public static final int ExceptionLogLevel_WithMessage
public static final int ExceptionLogLevel_WithStackTrace
public static final int LoggingFrequency_Medium
public static final int LoggingFrequency_Low
public static final int LoggingFrequency_High
public static final int DebugLevel_Off
public static final int DebugLevel_Lowest
public static final int DebugLevel_Low
public static final int DebugLevel_Medium
public static final int DebugLevel_High
public static final int DebugLevel_Highest
Constructor Detail |
public Logger(int loggingType)
loggingType
- is to tell if caching of log messages is required or not.
Its value is taken from one of the constants loggingType_CacheAndLog
and loggingType_LogImmediatly.public Logger(java.lang.String logFileName, int loggingType, int loggingFrequency) throws java.io.IOException
logFileName
- is the name of the file to which the log is to be generated.loggingType
- is to indicate if caching of log messages is required or not.
This parameter takes the value from one of the constants loggingType_CacheAndLog
and loggingType_LogImmediatly.loggingFrequency
- is to indicate the frequency of doing the logging activities.
Value of this parameter will be used only if log messages are cached.
This parameter takes the value from one of the constants loggingFrequency_Medium,
loggingFrequency_Low and loggingFrequency_High.Method Detail |
public void logMessageWithoutCaching(java.lang.String message)
message
- Is the actual string that will be logged into the log devices.public void logDebugMessage(int debugLevel, java.lang.String message)
debugLevel
- Is the parameter that will write the string information about log level.
Takes its value from one of the constants :
1. debugLevel_Off
2. debugLevel_Lowest
3. debugLevel_Low
4. debugLevel_Medium
5. debugLevel_High
6. debugLevel_Highmessage
- Is the actual string that will be logged into the log devices.public void logMessage(int messageType, java.lang.String message, java.lang.String customMessageTitle)
messageType
- Is the parameter that will write the string information about log level.
Takes its value from one of the constants :
1. MsgType_UserDef
2. MsgType_Info
3. MsgType_Warning
4. MsgType_Error
5. MsgType_Critical
6. MsgType_Exceptionmessage
- Is the actual string that will be logged into the log devices.customMessageTitle
- Is the parameter that carries the title of the custom log level,
"messageType" parameter takes the value MsgType_UserDef, or
else will be null.public void logException(java.lang.Throwable catchedException, int exceptionLogLevel)
catchedException
- Is the parameter that carries the exception object whose
information is to be logged.exceptionLogLevel
- Is the parameter that will write the string information about
log level for exceptions.Takes its value from one of the constants:
1. ExceptionLogLevel_OriginOnly
2. ExceptionLogLevel_WithMessage
3. ExceptionLogLevel_WithStackTracepublic void logExceptionWithMessage(java.lang.Throwable catchedException, int exceptionLogLevel, int messageType, java.lang.String message, java.lang.String customMessageTitle)
catchedException
- Is the parameter that carries the exception object whose
information is to be logged.exceptionLogLevel
- Is the parameter that will write the string information about
log level for exceptions.Takes its value from one of the constants:
1. ExceptionLogLevel_OriginOnly
2. ExceptionLogLevel_WithMessage
3. ExceptionLogLevel_WithStackTracemessageType
- Is the parameter that will write the string information about log level.
Takes its value from one of the constants :
1. MsgType_UserDef
2. MsgType_Info
3. MsgType_Warning
4. MsgType_Error
5. MsgType_Critical
6. MsgType_Exceptionmessage
- Is the actual string that will be logged into the log devices.customMessageTitle
- Is the parameter that carries the title of the custom log level,
"messageType" parameter takes the value Msgype_UserDef, or
else will be null.public void run()
run
in class java.lang.Thread
public void setLogFile(java.lang.String logFileName) throws java.io.IOException
logFileName
- Is to carry the file name that should be set as the log file.java.io.IOException
- public void setLogFile(java.io.FileOutputStream logFile) throws java.io.IOException
logFile
- Is the FileOutputStream object that should be set as the log file.java.io.IOException
- public java.io.FileOutputStream getLogFile()
public void setConsoleLogging(boolean isConsoleLog)
isConsoleLog
- If carries a value "true" then the next messages will be
logged into the console also, or else they wont be logged to the console.public boolean getConsoleLogging()
public void setDebugLevel(int debugLevel)
debugLevel
- is to set the dubug level and it takes effect immediatlypublic int getDebugLevel()
public void addExtraLogDevice(java.io.OutputStream logStream)
logStream
- Is the extra log device to which the log is to be written.public void addExtraLogDevice(java.io.Writer logWriter)
logWriter
- Is the extra log device to which the log is to be written.public void removeAllExtraLogDevices()
public void setLogFormat(int logFormat)
logFormat
- Is to set the Logger object's logging format. It can take
the value from one of the following.
1. logFormat_TimeStampFirst
2. logFormat_MsgTypeFirstpublic int getLogFormat()
public void finalize()
finalize
in class java.lang.Object
public void logException(VCException catchedException, java.lang.String source)
catchedException
- Is the parameter that carries the CORBA exception object whose
information is to be logged.source
- IS the string carrying the location of the object which is the source of this exceptionpublic void logException(IgnorableException iex, java.lang.String source)
catchedException
- Is the parameter that carries the CORBA exception
which is not serious and can be ignored , and its information will be logged.source
- IS the string carrying the location of the object which is the source of this exception
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |