public class SimpleLogger
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
SimpleLogger.LogLevel
Supported log levels.
|
static class |
SimpleLogger.LogRotationType
Supported types of log file rotations.
|
Constructor and Description |
---|
SimpleLogger() |
Modifier and Type | Method and Description |
---|---|
static void |
close()
Close the log file and reset the JVM's output to standard out and error.
|
static void |
debug(java.lang.Object data)
Write the data to the log file if the logLevel is at least INFO.
|
static void |
debugDump(java.lang.String title,
byte[] data)
Convert the data to a HEX table and write it to the log file if the logLevel is at least DEBUG.
|
static void |
error(java.lang.Object data)
Write the data to the log file if the logLevel is at least ERROR.
|
static void |
errorDump(java.lang.String title,
byte[] data)
Convert the data to a HEX table and write it to the log file if the logLevel is at least ERROR.
|
static void |
info(java.lang.Object data)
Write the data to the log file if the logLevel is at least INFO.
|
static void |
infoDump(java.lang.String title,
byte[] data)
Convert the data to a HEX table and write it to the log file if the logLevel is at least INFO.
|
static void |
setIncludePackageName(boolean flag)
Set whether or not to include the package name with the class name.
|
static void |
setLevel(SimpleLogger.LogLevel ll)
Set the log level.
|
static void |
setLogFile()
Create the directory, if necessary, construct the logPathAndFileName and the call
handleSettingPrintStream method to open/create the logfile.
|
static void |
setLogFile(java.lang.String logFileName)
Create the directory, if necessary, construct the logPathAndFileName and the call
handleSettingPrintStream method to open/create the logfile.
|
static void |
setLogFile(java.lang.String logFileName,
java.lang.String logDirectory)
Create the directory, if necessary, construct the logPathAndFileName and the call
handleSettingPrintStream method to open/create the logfile.
|
static void |
setMaxBackupFiles(int maxCount)
Set the maximum number of backup files.
|
static void |
setMaxLogFileSize(int maxSize)
Set the maximum log file size.
|
static void |
setRotationType(SimpleLogger.LogRotationType rt)
Set the log rotation type.
|
static void |
warn(java.lang.Object data)
Write the data to the log file if the logLevel is at least WARN.
|
static void |
warnDump(java.lang.String title,
byte[] data)
Convert the data to a HEX table and write it to the log file if the logLevel is at least WARN.
|
public static void setLogFile() throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public static void setLogFile(java.lang.String logFileName) throws java.lang.IllegalArgumentException
logFileName
- The name of the log filejava.lang.IllegalArgumentException
public static void setLogFile(java.lang.String logFileName, java.lang.String logDirectory) throws java.lang.IllegalArgumentException
logFileName
- The name of the log filelogDirectory
- The directory where to write the log file to. Default is current working directory.java.lang.IllegalArgumentException
public static void close()
public static void setIncludePackageName(boolean flag)
flag
- Indicate whether the package name should be included with the class name.public static void setLevel(SimpleLogger.LogLevel ll)
ll
- the log level to be used.public static void setMaxBackupFiles(int maxCount)
maxCount
- the maximum number of backup files to be kept.public static void setMaxLogFileSize(int maxSize)
maxSize
- the maximum size of the log file before rotation. Only valid in log level is set to LogRotationType.SIZEpublic static void setRotationType(SimpleLogger.LogRotationType rt)
rt
- the type of log rotation to be used.public static void error(java.lang.Object data)
data
- the data to be written to the log file.public static void warn(java.lang.Object data)
data
- the data to be written to the log file.public static void info(java.lang.Object data)
data
- the data to be written to the log file.public static void debug(java.lang.Object data)
data
- the data to be written to the log file.public static void errorDump(java.lang.String title, byte[] data)
title
- the title for the HEX dump.data
- the data, convert to HEX, to be written to the log file.public static void warnDump(java.lang.String title, byte[] data)
title
- the title for the HEX dump.data
- the data, convert to HEX, to be written to the log file.public static void infoDump(java.lang.String title, byte[] data)
title
- the title for the HEX dump.data
- the data, convert to HEX, to be written to the log file.public static void debugDump(java.lang.String title, byte[] data)
title
- the title for the HEX dump.data
- the data, convert to HEX, to be written to the log file.