Package edu.gvsu.kurmasz.warszawa.log
Class SimpleLog
java.lang.Object
edu.gvsu.kurmasz.warszawa.log.SimpleLog
- Direct Known Subclasses:
Log
public class SimpleLog
extends java.lang.Object
A very simple logging utility.
- Author:
- Zachary Kurmas
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description voidconfigure(java.io.PrintWriter output, int threshold)Configure the loggervoidprintln(int level, java.lang.String message)Print a logging messagevoidsetOutput(java.io.PrintWriter log)Set the stream to which to write logging messages.voidsetThreshold(int threshold)Set the message threshold.voidsetThresholdToMax()Effectively suspends logging by setting the threshold to the maximum possible value (unless, of course, a message is printed with levelInteger.MAX_VALUE).booleanwillLog(int level)Test whether logging is enabled for the specified level.
-
Constructor Details
-
SimpleLog
public SimpleLog()Default log that produces no output. -
SimpleLog
public SimpleLog(java.io.PrintWriter log, int threshold)Constructor- Parameters:
log- where to write the log datathreshold- Minimum level of importance to be logged. (In other words, only messages with values at leastdebugLevelare logged.)
-
-
Method Details
-
willLog
public boolean willLog(int level)Test whether logging is enabled for the specified level. (Subclasses can use this method to avoid performing calculations that won't be printed.)- Parameters:
level- the importance of the message- Returns:
trueif messages oflevelwill be printed.falseotherwise.
-
println
public void println(int level, java.lang.String message)Print a logging message- Parameters:
level- the importance of the message. (Higher values are more important.)message- the message to print.
-
setThreshold
public void setThreshold(int threshold)Set the message threshold. Lower values produce more messages.- Parameters:
threshold- Minimum level of importance to be logged. (In other words, only messages with values at leastdebugLevelare logged.)
-
setThresholdToMax
public void setThresholdToMax()Effectively suspends logging by setting the threshold to the maximum possible value (unless, of course, a message is printed with levelInteger.MAX_VALUE). -
setOutput
public void setOutput(java.io.PrintWriter log)Set the stream to which to write logging messages.- Parameters:
log- the writer to which to write logging messages.
-
configure
public void configure(java.io.PrintWriter output, int threshold)Configure the logger- Parameters:
output- the file to which to write logging messages. An empty or null string will deactivate logging.threshold- Minimum level of importance to be logged. (In other words, only messages with values at leastdebugLevelare logged.)
-