public class CADILog
extends java.lang.Object
logDebug(String)
, logInfo(String)
,
logWarning(String)
, logError(String)
.
Usage example:
construct
logInfo or logWarning or logError or logDebug methods
Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
CADILog()
Constructor.
|
CADILog(java.lang.String fileName,
boolean useXMLFormat)
Constructor.
|
CADILog(java.lang.String fileName,
boolean useXMLFormat,
int logLevel) |
CADILog(java.lang.String fileName,
int logLevel) |
Modifier and Type | Method and Description |
---|---|
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.
|
boolean |
isLog(int level)
Check if logs are enabled for the level
level . |
void |
list(java.io.PrintStream out)
Prints this CADI Log fields out to the specified output stream.
|
void |
log(int level,
java.lang.String str) |
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.
|
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
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.public CADILog(java.lang.String fileName, int logLevel)
fileName
- logLevel
- public CADILog(java.lang.String fileName, boolean useXMLFormat, int logLevel)
fileName
- useXMLFormat
- logLevel
- 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 log(int level, java.lang.String str)
level
- str
- public boolean isLog(int level)
level
.level
- level to be checked.true if logs are enabled. Otherwise, returns false
.
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 java.lang.String toString()
toString
in class java.lang.Object
public 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()
CADI - Copyright (C) 2007
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
Group on Interactive Coding of Images (GICI) (contact)