Package weka.core
Class Debug.Log
- java.lang.Object
-
- weka.core.Debug.Log
-
- All Implemented Interfaces:
java.io.Serializable
,RevisionHandler
- Enclosing class:
- Debug
public static class Debug.Log extends java.lang.Object implements java.io.Serializable, RevisionHandler
A helper class for logging stuff. Uses the java.util.logging package. If this approach seems an "overkill" (it can create quite a few log files if used in different threads), one can use the Debug.SimpleLog class.- Version:
- $Revision: 7519 $
- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
Debug.SimpleLog
, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Log()
default constructor, uses only stdoutLog(java.lang.String filename)
creates a logger that logs into the specified file, if null then only stdout is used.Log(java.lang.String filename, int size, int numFiles)
creates a logger that logs into the specified file, if null then only stdout is used.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getFilename()
returns the filename of the log, can be nullint
getNumFiles()
returns the number of files being usedjava.lang.String
getRevision()
Returns the revision string.int
getSize()
returns the size of the filesvoid
log(java.util.logging.Level level, java.lang.String message)
logs the given messagevoid
log(java.util.logging.Level level, java.lang.String sourceclass, java.lang.String message)
prints the given message with the specified levelvoid
log(java.util.logging.Level level, java.lang.String sourceclass, java.lang.String sourcemethod, java.lang.String message)
prints the given message with the specified levelvoid
logSystemInfo()
a convenience method for dumping the current system info in the log filestatic java.util.logging.Level
stringToLevel(java.lang.String level)
turns the string representing a level, e.g., "FINE" or "ALL" into the corresponding level (case-insensitive).java.lang.String
toString()
returns a string representation of the logger
-
-
-
Constructor Detail
-
Log
public Log()
default constructor, uses only stdout
-
Log
public Log(java.lang.String filename)
creates a logger that logs into the specified file, if null then only stdout is used. It uses 1,000,000 bytes for file size and 1 file.- Parameters:
filename
- the file to log into
-
Log
public Log(java.lang.String filename, int size, int numFiles)
creates a logger that logs into the specified file, if null then only stdout is used.- Parameters:
filename
- the file to log intosize
- the size of the files in bytesnumFiles
- the number of files for rotating
-
-
Method Detail
-
stringToLevel
public static java.util.logging.Level stringToLevel(java.lang.String level)
turns the string representing a level, e.g., "FINE" or "ALL" into the corresponding level (case-insensitive). The default is ALL.- Parameters:
level
- the string to return a level for- Returns:
- the corresponding level or the default
-
getFilename
public java.lang.String getFilename()
returns the filename of the log, can be null- Returns:
- the filename of the log
-
getSize
public int getSize()
returns the size of the files- Returns:
- the size of a file
-
getNumFiles
public int getNumFiles()
returns the number of files being used- Returns:
- the number of files
-
log
public void log(java.util.logging.Level level, java.lang.String message)
logs the given message- Parameters:
level
- the level of severitymessage
- the message to log
-
log
public void log(java.util.logging.Level level, java.lang.String sourceclass, java.lang.String message)
prints the given message with the specified level- Parameters:
level
- the level of loggingsourceclass
- the class that logs the messagemessage
- the message to print
-
log
public void log(java.util.logging.Level level, java.lang.String sourceclass, java.lang.String sourcemethod, java.lang.String message)
prints the given message with the specified level- Parameters:
level
- the level of loggingsourceclass
- the class that logs the messagesourcemethod
- the method that logs the messagemessage
- the message to print
-
logSystemInfo
public void logSystemInfo()
a convenience method for dumping the current system info in the log file- See Also:
SystemInfo
-
toString
public java.lang.String toString()
returns a string representation of the logger- Overrides:
toString
in classjava.lang.Object
- Returns:
- a string representation of the logger
-
getRevision
public java.lang.String getRevision()
Returns the revision string.- Specified by:
getRevision
in interfaceRevisionHandler
- Returns:
- the revision
-
-