Class Log

java.lang.Object
mastermind.utils.Log

public class Log extends Object
Represents a singleton logger for recording messages with different severity levels.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Represents the severity levels of log messages.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Adds sink to which log messages will be written.
    static void
    Logs a message with the DEBUG severity level.
    static void
    Logs a message with the ERROR severity level.
    static void
    Logs a message with the FATAL severity level and exits the program.
    static void
    info(String msg)
    Logs a message with the INFO severity level.
    static void
    Sets the severity level of the logger.
    static void
    setLogToStdout(boolean logToStdout)
    Sets whether log messages should be written to stdout.
    static void
    Logs a message with the TRACE severity level.
    static void
    Logs a message with the WARNING severity level.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • addSink

      public static void addSink(OutputStream sink)
      Adds sink to which log messages will be written.
      Parameters:
      sink - The output stream to add.
    • setLevel

      public static void setLevel(Log.Severity level)
      Sets the severity level of the logger.

      Only messages with a severity level greater than or equal to this level will be logged.

      Parameters:
      level - The severity level to set.
    • setLogToStdout

      public static void setLogToStdout(boolean logToStdout)
      Sets whether log messages should be written to stdout.
      Parameters:
      logToStdout - The flag to set.
    • trace

      public static void trace(String msg)
      Logs a message with the TRACE severity level.
      Parameters:
      msg - The message to log.
    • debug

      public static void debug(String msg)
      Logs a message with the DEBUG severity level.
      Parameters:
      msg - The message to log.
    • info

      public static void info(String msg)
      Logs a message with the INFO severity level.
      Parameters:
      msg - The message to log.
    • warning

      public static void warning(String msg)
      Logs a message with the WARNING severity level.
      Parameters:
      msg - The message to log.
    • error

      public static void error(String msg)
      Logs a message with the ERROR severity level.
      Parameters:
      msg - The message to log.
    • fatal

      public static void fatal(String msg)
      Logs a message with the FATAL severity level and exits the program.
      Parameters:
      msg - The message to log.