Package weka.core
Class Debug
java.lang.Object
weka.core.Debug
- All Implemented Interfaces:
Serializable
,RevisionHandler
A helper class for debug output, logging, clocking, etc.
- Version:
- $Revision: 8034 $
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A little helper class for clocking and outputting times.static class
contains debug methodsstatic class
A helper class for logging stuff.static class
This extended Random class enables one to print the generated random numbers etc., before they are returned.static class
A little, simple helper class for logging stuff.static class
A class that can be used for timestamps in files, The toString() method simply returns the associated Date object in a timestamp format. -
Field Summary
Modifier and TypeFieldDescriptionstatic final Level
the log level Allstatic final Level
the log level Vonfigstatic final Level
the log level Finestatic final Level
the log level Finerstatic final Level
the log level Fineststatic final Level
the log level Infostatic final Level
the log level Off - i.e., no loggingstatic final Level
the log level Severestatic final Level
the log level Warning -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetClock()
returns the instance of the Clock that is internally usedstatic String
returns the current working directory of the userboolean
returns whether the logging is enabledstatic String
returns the home directory of the userReturns the revision string.static String
returns the system temp directorystatic Object
loadFromFile
(String filename) deserializes the content of the file and returns it, null if an error occurred.void
prints the given message with level INFOvoid
prints the given message with the specified level and an empty sourceclassvoid
prints the given message with the specified levelvoid
prints the given message with the specified levelstatic Debug.Clock
newClock()
returns a new instance of a clockstatic Debug.Log
returns a new Log instancestatic Random
returns a default debug random object, with no particular seed and debugging enabled.static Random
newRandom
(int seed) returns a debug random object with the specified seed and debugging enabled.static Debug.Timestamp
returns a default timestamp for the current date/timestatic boolean
saveToFile
(String filename, Object o) writes the serialized object to the speicified filevoid
setEnabled
(boolean value) sets whether the logging is enabled or notvoid
starts the clockvoid
stops the clock and prints the message associated with the time, but only if the logging is enabled.static Level
stringToLevel
(String level) turns the string representing a level, e.g., "FINE" or "ALL" into the corresponding level (case-insensitive).static boolean
writeToFile
(String filename, Object obj) Writes the given object to the specified file.static boolean
writeToFile
(String filename, Object obj, boolean append) Writes the given object to the specified file.static boolean
writeToFile
(String filename, String message) Writes the given message to the specified file.static boolean
writeToFile
(String filename, String message, boolean append) Writes the given message to the specified file.
-
Field Details
-
ALL
the log level All -
CONFIG
the log level Vonfig -
FINE
the log level Fine -
FINER
the log level Finer -
FINEST
the log level Finest -
INFO
the log level Info -
OFF
the log level Off - i.e., no logging -
SEVERE
the log level Severe -
WARNING
the log level Warning
-
-
Constructor Details
-
Debug
public Debug()default constructor, prints only to stdout -
Debug
logs the output to the specified file (and stdout). Size is 1,000,000 bytes and 1 file.- Parameters:
filename
- the name of the log
-
Debug
logs the output- Parameters:
filename
- the name of the logsize
- the size of the files in bytesnumFiles
- the number of files for rotating
-
-
Method Details
-
stringToLevel
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
-
newLog
returns a new Log instance- Parameters:
filename
- the name of the logsize
- the size of the files in bytesnumFiles
- the number of files for rotating- Returns:
- the log instance
-
log
prints the given message with level INFO- Parameters:
message
- the message to print
-
log
prints the given message with the specified level and an empty sourceclass- Parameters:
level
- the level of loggingmessage
- the message to print
-
log
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
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
-
setEnabled
public void setEnabled(boolean value) sets whether the logging is enabled or not- Parameters:
value
- if true logging will be enabled
-
getEnabled
public boolean getEnabled()returns whether the logging is enabled- Returns:
- true if the logging is enabled
-
newClock
returns a new instance of a clock- Returns:
- a new instance of a Clock
-
getClock
returns the instance of the Clock that is internally used- Returns:
- the clock that's being used
-
startClock
public void startClock()starts the clock -
stopClock
stops the clock and prints the message associated with the time, but only if the logging is enabled.- Parameters:
message
- the message to print- See Also:
-
newRandom
returns a default debug random object, with no particular seed and debugging enabled.- Returns:
- a new instance of a Random object
-
newRandom
returns a debug random object with the specified seed and debugging enabled.- Parameters:
seed
- the seed value- Returns:
- a new instance of a Random object
-
newTimestamp
returns a default timestamp for the current date/time- Returns:
- a new timestamp
-
getTempDir
returns the system temp directory- Returns:
- the temp directory
-
getHomeDir
returns the home directory of the user- Returns:
- the user's home directory
-
getCurrentDir
returns the current working directory of the user- Returns:
- the user's current working directory
-
writeToFile
Writes the given object to the specified file. The string representation of the object is appended to the file.- Parameters:
filename
- the file to write toobj
- the object to write to the file- Returns:
- true if writing was successful
-
writeToFile
Writes the given message to the specified file. The message is appended to the file.- Parameters:
filename
- the file to write tomessage
- the message to write- Returns:
- true if writing was successful
-
writeToFile
Writes the given object to the specified file. The string representation of the object is either appended or replaces the current content of the file.- Parameters:
filename
- the file to write toobj
- the object to write to the fileappend
- whether to append the message or not- Returns:
- true if writing was successful
-
writeToFile
Writes the given message to the specified file. The message is either appended or replaces the current content of the file.- Parameters:
filename
- the file to write tomessage
- the message to writeappend
- whether to append the message or not- Returns:
- true if writing was successful
-
saveToFile
writes the serialized object to the speicified file- Parameters:
filename
- the file to serialize the object too
- the object to serialize- Returns:
- true if writing was successful
-
loadFromFile
deserializes the content of the file and returns it, null if an error occurred.- Parameters:
filename
- the name of the file to deserialize- Returns:
- the deserialized content, null if problem occurred
-
getRevision
Returns the revision string.- Specified by:
getRevision
in interfaceRevisionHandler
- Returns:
- the revision
-