Class Log

java.lang.Object
edu.gvsu.kurmasz.warszawa.log.SimpleLog
edu.gvsu.kurmasz.warszawa.log.Log

public class Log
extends SimpleLog
A SimpleLog with extended configurability.
Author:
Zachary Kurmas
  • Constructor Summary

    Constructors 
    Constructor Description
    Log()
    Constructs a silent log.
    Log​(java.io.OutputStream stream, int threshold)
    Constructor
    Log​(java.io.PrintWriter log, int threshold)
    Constructor
    Log​(java.lang.String logfile, int threshold)
    Constructor
  • Method Summary

    Modifier and Type Method Description
    void close()
    Close the underlying PrintWriter.
    void configure​(java.io.OutputStream stream, int threshold)
    Configure the logger
    void configure​(java.lang.String logfile, int threshold)
    Configure the logger
    void configureOrQuit​(java.lang.String file, int threshold)
    Configure the logger or quit if the file cannot be opened for writing.
    void configureOrQuit​(java.lang.String file, int threshold, java.io.PrintStream error, int exitValue)
    Configure the logger or quit if the file cannot be opened for writing.
    static void main​(java.lang.String[] args)  
    static Log makeLogOrQuit​(java.lang.String file, int threshold)
    Try to create a Log attached to the specified file.
    static Log makeLogOrQuit​(java.lang.String file, int threshold, java.io.PrintStream error, int exitValue)
    Try to create a Log attached to the specified file.
    void setOutput​(java.io.OutputStream stream)
    Specifies the stream to which to write the logging messages.
    void setOutput​(java.lang.String filename)
    Specifies the file to which to write the logging messages
    void setOutputOrQuit​(java.lang.String file)
    Specifies the file to which to write the logging messages or quit if the file is not writable.
    void setOutputOrQuit​(java.lang.String filename, java.io.PrintStream error, int exit_value)
    Specifies the writer to which to write the logging messages or quit if the file is not writable.

    Methods inherited from class edu.gvsu.kurmasz.warszawa.log.SimpleLog

    configure, println, setOutput, setThreshold, setThresholdToMax, willLog

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Log

      public Log()
      Constructs a silent log.
    • Log

      public Log​(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.)
    • Log

      public Log​(java.lang.String logfile, int threshold) throws java.io.FileNotFoundException
      Constructor
      Parameters:
      logfile - 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.)
      Throws:
      java.io.FileNotFoundException - if logfile can't be written to
    • Log

      public Log​(java.io.OutputStream stream, int threshold)
      Constructor
      Parameters:
      stream - OutputStream to which 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

    • setOutput

      public void setOutput​(java.io.OutputStream stream)
      Specifies the stream to which to write the logging messages.
      Parameters:
      stream - the stream
    • setOutput

      public void setOutput​(java.lang.String filename) throws java.io.FileNotFoundException
      Specifies the file to which to write the logging messages
      Parameters:
      filename - the file to which to write logging messages. An empty or null string will deactivate logging.
      Throws:
      java.io.FileNotFoundException - if logfile can't be written to
    • setOutputOrQuit

      public void setOutputOrQuit​(java.lang.String filename, java.io.PrintStream error, int exit_value)
      Specifies the writer to which to write the logging messages or quit if the file is not writable.
      Parameters:
      filename - the file to which to write logging messages
      error - the stream to which to write error messages
      exit_value - exit value for process should log creation fail
    • setOutputOrQuit

      public void setOutputOrQuit​(java.lang.String file)
      Specifies the file to which to write the logging messages or quit if the file is not writable. (Process exits with a return value of 1.)
      Parameters:
      file - the file to which to write logging messages
    • configure

      public void configure​(java.io.OutputStream stream, int threshold)
      Configure the logger
      Parameters:
      stream - the OutputStream to which to write logging messages.
      threshold - Minimum level of importance to be logged. (In other words, only messages with values at least threshold are logged.)
    • configure

      public void configure​(java.lang.String logfile, int threshold) throws java.io.FileNotFoundException
      Configure the logger
      Parameters:
      logfile - 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 threshold are logged.)
      Throws:
      java.io.FileNotFoundException - if logfile cannot be opened for writing.
    • configureOrQuit

      public void configureOrQuit​(java.lang.String file, int threshold, java.io.PrintStream error, int exitValue)
      Configure the logger or quit if the file cannot be opened for writing.
      Parameters:
      file - 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 threshold are logged.)
      error - the stream to which to write error messages
      exitValue - exit value for process should log creation fail
    • configureOrQuit

      public void configureOrQuit​(java.lang.String file, int threshold)
      Configure the logger or quit if the file cannot be opened for writing.
      Parameters:
      file - 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 threshold are logged.)
    • makeLogOrQuit

      public static Log makeLogOrQuit​(java.lang.String file, int threshold, java.io.PrintStream error, int exitValue)
      Try to create a Log attached to the specified file. If the file is not writable, print an error message and quit.
      Parameters:
      file - the file to which to write logging messages
      threshold - Minimum level of importance to be logged. (In other words, only messages with values at least theshold are logged.)
      error - the stream to which to write error messages
      exitValue - exit value for process should log creation fail
      Returns:
      a valid Log object
    • makeLogOrQuit

      public static Log makeLogOrQuit​(java.lang.String file, int threshold)
      Try to create a Log attached to the specified file. If the file is not writable, print an error message and quit.
      Parameters:
      file - the file to which to write logging messages
      threshold - Minimum level of importance to be logged. (In other words, only messages with values at least debugLevel are logged.)
      Returns:
      a valid Log object
    • close

      public void close()
      Close the underlying PrintWriter.
    • main

      public static void main​(java.lang.String[] args)