public class Debug extends java.lang.Object implements java.io.Serializable, RevisionHandler
Modifier and Type | Class and Description |
---|---|
static class |
Debug.Clock
A little helper class for clocking and outputting times.
|
static class |
Debug.DBO
contains debug methods
|
static class |
Debug.Log
A helper class for logging stuff.
|
static class |
Debug.Random
This extended Random class enables one to print the generated random
numbers etc., before they are returned.
|
static class |
Debug.SimpleLog
A little, simple helper class for logging stuff.
|
static class |
Debug.Timestamp
A class that can be used for timestamps in files, The toString() method
simply returns the associated Date object in a timestamp format.
|
Modifier and Type | Field and Description |
---|---|
static java.util.logging.Level |
ALL
the log level All
|
static java.util.logging.Level |
CONFIG
the log level Vonfig
|
static java.util.logging.Level |
FINE
the log level Fine
|
static java.util.logging.Level |
FINER
the log level Finer
|
static java.util.logging.Level |
FINEST
the log level Finest
|
static java.util.logging.Level |
INFO
the log level Info
|
static java.util.logging.Level |
OFF
the log level Off - i.e., no logging
|
static java.util.logging.Level |
SEVERE
the log level Severe
|
static java.util.logging.Level |
WARNING
the log level Warning
|
Constructor and Description |
---|
Debug()
default constructor, prints only to stdout
|
Debug(java.lang.String filename)
logs the output to the specified file (and stdout).
|
Debug(java.lang.String filename,
int size,
int numFiles)
logs the output
|
Modifier and Type | Method and Description |
---|---|
Debug.Clock |
getClock()
returns the instance of the Clock that is internally used
|
static java.lang.String |
getCurrentDir()
returns the current working directory of the user
|
boolean |
getEnabled()
returns whether the logging is enabled
|
static java.lang.String |
getHomeDir()
returns the home directory of the user
|
java.lang.String |
getRevision()
Returns the revision string.
|
static java.lang.String |
getTempDir()
returns the system temp directory
|
static java.lang.Object |
loadFromFile(java.lang.String filename)
deserializes the content of the file and returns it, null if an error
occurred.
|
void |
log(java.util.logging.Level level,
java.lang.String message)
prints the given message with the specified level and an empty sourceclass
|
void |
log(java.util.logging.Level level,
java.lang.String sourceclass,
java.lang.String message)
prints the given message with the specified level
|
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
|
void |
log(java.lang.String message)
prints the given message with level INFO
|
static Debug.Clock |
newClock()
returns a new instance of a clock
|
static Debug.Log |
newLog(java.lang.String filename,
int size,
int numFiles)
returns a new Log instance
|
static java.util.Random |
newRandom()
returns a default debug random object, with no particular seed and
debugging enabled.
|
static java.util.Random |
newRandom(int seed)
returns a debug random object with the specified seed and debugging
enabled.
|
static Debug.Timestamp |
newTimestamp()
returns a default timestamp for the current date/time
|
static boolean |
saveToFile(java.lang.String filename,
java.lang.Object o)
writes the serialized object to the speicified file
|
void |
setEnabled(boolean value)
sets whether the logging is enabled or not
|
void |
startClock()
starts the clock
|
void |
stopClock(java.lang.String message)
stops the clock and prints the message associated with the time, but only
if the logging is enabled.
|
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).
|
static boolean |
writeToFile(java.lang.String filename,
java.lang.Object obj)
Writes the given object to the specified file.
|
static boolean |
writeToFile(java.lang.String filename,
java.lang.Object obj,
boolean append)
Writes the given object to the specified file.
|
static boolean |
writeToFile(java.lang.String filename,
java.lang.String message)
Writes the given message to the specified file.
|
static boolean |
writeToFile(java.lang.String filename,
java.lang.String message,
boolean append)
Writes the given message to the specified file.
|
public static final java.util.logging.Level ALL
public static final java.util.logging.Level CONFIG
public static final java.util.logging.Level FINE
public static final java.util.logging.Level FINER
public static final java.util.logging.Level FINEST
public static final java.util.logging.Level INFO
public static final java.util.logging.Level OFF
public static final java.util.logging.Level SEVERE
public static final java.util.logging.Level WARNING
public Debug()
public Debug(java.lang.String filename)
filename
- the name of the logpublic Debug(java.lang.String filename, int size, int numFiles)
filename
- the name of the logsize
- the size of the files in bytesnumFiles
- the number of files for rotatingpublic static java.util.logging.Level stringToLevel(java.lang.String level)
level
- the string to return a level forpublic static Debug.Log newLog(java.lang.String filename, int size, int numFiles)
filename
- the name of the logsize
- the size of the files in bytesnumFiles
- the number of files for rotatingpublic void log(java.lang.String message)
message
- the message to printpublic void log(java.util.logging.Level level, java.lang.String message)
level
- the level of loggingmessage
- the message to printpublic void log(java.util.logging.Level level, java.lang.String sourceclass, java.lang.String message)
level
- the level of loggingsourceclass
- the class that logs the messagemessage
- the message to printpublic void log(java.util.logging.Level level, java.lang.String sourceclass, java.lang.String sourcemethod, java.lang.String message)
level
- the level of loggingsourceclass
- the class that logs the messagesourcemethod
- the method that logs the messagemessage
- the message to printpublic void setEnabled(boolean value)
value
- if true logging will be enabledpublic boolean getEnabled()
public static Debug.Clock newClock()
public Debug.Clock getClock()
public void startClock()
public void stopClock(java.lang.String message)
message
- the message to printgetEnabled()
public static java.util.Random newRandom()
public static java.util.Random newRandom(int seed)
seed
- the seed valuepublic static Debug.Timestamp newTimestamp()
public static java.lang.String getTempDir()
public static java.lang.String getHomeDir()
public static java.lang.String getCurrentDir()
public static boolean writeToFile(java.lang.String filename, java.lang.Object obj)
filename
- the file to write toobj
- the object to write to the filepublic static boolean writeToFile(java.lang.String filename, java.lang.String message)
filename
- the file to write tomessage
- the message to writepublic static boolean writeToFile(java.lang.String filename, java.lang.Object obj, boolean append)
filename
- the file to write toobj
- the object to write to the fileappend
- whether to append the message or notpublic static boolean writeToFile(java.lang.String filename, java.lang.String message, boolean append)
filename
- the file to write tomessage
- the message to writeappend
- whether to append the message or notpublic static boolean saveToFile(java.lang.String filename, java.lang.Object o)
filename
- the file to serialize the object too
- the object to serializepublic static java.lang.Object loadFromFile(java.lang.String filename)
filename
- the name of the file to deserializepublic java.lang.String getRevision()
getRevision
in interface RevisionHandler