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

    Constructors 
    Constructor Description
    SimpleLog()
    Default log that produces no output.
    SimpleLog​(java.io.PrintWriter log, int threshold)
    Constructor
  • Method Summary

    Modifier and Type Method Description
    void configure​(java.io.PrintWriter output, int threshold)
    Configure the logger
    void println​(int level, java.lang.String message)
    Print a logging message
    void setOutput​(java.io.PrintWriter log)
    Set the stream to which to write logging messages.
    void setThreshold​(int threshold)
    Set the message threshold.
    void setThresholdToMax()
    Effectively suspends logging by setting the threshold to the maximum possible value (unless, of course, a message is printed with level Integer.MAX_VALUE).
    boolean willLog​(int level)
    Test whether logging is enabled for the specified level.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 data
      threshold - Minimum level of importance to be logged. (In other words, only messages with values at least debugLevel are 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:
      true if messages of level will be printed. false otherwise.
    • 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 least debugLevel are 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 level Integer.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 least debugLevel are logged.)