|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.ObjectCADI.Common.Log.CADILog
public class CADILog
This class provides a wrapper for abstracting the destination and format
of the logs. The destination (standard output or file) and the format (plain
text or XML) are selected in the constructor. In addittion, four log types
are available: logDebug(String), logInfo(String),
logWarning(String), logError(String).
Usage example:
construct
logInfo or logWarning or logError or logDebug methods
| Field Summary | |
|---|---|
private int |
count
Indicates the number of files to use. |
private boolean |
enabled
Indicate whether logs are or not enabled. |
private java.util.logging.FileHandler |
fileHandler
|
private java.lang.String |
fileName
Is the file name where logs are done. |
static int |
LEVEL_DEBUG
|
static int |
LEVEL_ERROR
|
static int |
LEVEL_INFO
|
static int |
LEVEL_WARNING
|
private int |
limit
Indicates the maximum number of bytes to write in any file. |
private java.util.logging.Logger |
logger
|
private int |
logLevel
Indicates which is the severity of the messages that it will record. |
private boolean |
logToFile
Indicates whether logs are saved in a file or they are printed in the standard output. |
private java.io.OutputStream |
outputStream
|
private java.util.logging.StreamHandler |
streamHandler
|
private boolean |
useXMLFormat
Indicates if XML format is used to create the log file. |
| Constructor Summary | |
|---|---|
CADILog()
Constructor. |
|
CADILog(java.lang.String fileName,
boolean useXMLFormat)
Constructor. |
|
| Method Summary | |
|---|---|
void |
close()
Closes the log. |
void |
configure(java.lang.String fileName,
boolean useXMLFormat)
Configures the file name and log format parameters. |
private void |
flush()
Flush any buffered messages. |
java.lang.String |
getFileName()
Returns the fileName attribute. |
int |
getLogLevel()
Retuns the logLevel attribute. |
boolean |
isEnabled()
Checks whether the logs are enabled. |
void |
list(java.io.PrintStream out)
Prints this CADI Log fields out to the specified output stream. |
void |
logDebug(java.lang.String str)
Method used to the DEBUG logs. |
void |
logError(java.lang.String str)
Method used to the ERROR logs. |
void |
logInfo(java.lang.String str)
Method used to the INFO logs. |
void |
logWarning(java.lang.String str)
Method used to the WARNING logs. |
void |
setEnabled(boolean enabled)
Sets the log enabled or disabled. |
void |
setLogLevel(int logLevel)
Sets the logLevel attribute. |
void |
setParameters(java.lang.String fileName,
boolean useXMLFormat)
Sets the file name and log format parameters. |
java.lang.String |
toString()
|
boolean |
useXMLFormat()
Checks whether data are logged using plain text or XML format. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private boolean enabled
private boolean useXMLFormat
Default value: false (simple format is used)
private boolean logToFile
private java.lang.String fileName
null logs are
printed out in the standard output.
private int logLevel
logLevel attribute.
Allowed values: LEVEL_DEBUG, LEVEL_INFO,
LEVEL_INFO and, LEVEL_ERROR.
public static final int LEVEL_DEBUG
public static final int LEVEL_INFO
public static final int LEVEL_WARNING
public static final int LEVEL_ERROR
private java.util.logging.Logger logger
private java.util.logging.FileHandler fileHandler
private java.util.logging.StreamHandler streamHandler
private java.io.OutputStream outputStream
private int limit
private int count
| Constructor Detail |
|---|
public CADILog()
public CADILog(java.lang.String fileName,
boolean useXMLFormat)
fileName - the file name where logs are writen. If it is null, logs
are displayed in the standard ouptut.useXMLFormat - if true, logs are formated using XML format.
Otherwise, standard format is used.| Method Detail |
|---|
public void setParameters(java.lang.String fileName,
boolean useXMLFormat)
fileName - the file name where logs are writen. If it is null, logs
are displayed in the standard ouptut.useXMLFormat - if true, logs are formated using XML format.
Otherwise, standard format is used.public void logDebug(java.lang.String str)
DEBUG logs.
str - the string message.public void logInfo(java.lang.String str)
INFO logs.
str - the string message.public void logWarning(java.lang.String str)
WARNING logs.
str - the string message.public void logError(java.lang.String str)
ERROR logs.
str - the string message.public void setEnabled(boolean enabled)
enabled - if true, logs are enabled.
Otherwise, logs are disabled.public void setLogLevel(int logLevel)
logLevel attribute.
logLevel - see logLevel attribute.public void close()
public boolean isEnabled()
true if the logs are enabled.public boolean useXMLFormat()
true if data log format is XML. Otherwise,
returns false.public java.lang.String getFileName()
fileName attribute.
fileName attribue.public int getLogLevel()
logLevel attribute.
logLevel attribute.public java.lang.String toString()
toString in class java.lang.Objectpublic void list(java.io.PrintStream out)
out - an output stream.
public void configure(java.lang.String fileName,
boolean useXMLFormat)
fileName - the file name where logs are writen. If it is null, logs
are displayed in the standard ouptut.useXMLFormat - if true, logs are formated using XML format.
Otherwise, standard format is used.private void flush()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||