Class PrintStreamLogger

  • All Implemented Interfaces:
    InvokerLogger
    Direct Known Subclasses:
    SystemOutLogger

    public class PrintStreamLogger
    extends java.lang.Object
    implements InvokerLogger
    Offers a logger that writes to a print stream like System.out.
    Since:
    2.0.9
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.io.PrintStream out
      The print stream to write to, never null.
      private int threshold
      The threshold used to filter messages.
    • Constructor Summary

      Constructors 
      Constructor Description
      PrintStreamLogger()
      Creates a new logger that writes to System.out and has a threshold of InvokerLogger.INFO.
      PrintStreamLogger​(java.io.PrintStream out, int threshold)
      Creates a new logger that writes to the specified print stream.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void debug​(java.lang.String message)
      Logs the specified debug message.
      void debug​(java.lang.String message, java.lang.Throwable throwable)
      Logs the specified debug message and the accompanying exception.
      void error​(java.lang.String message)
      Logs the specified error message.
      void error​(java.lang.String message, java.lang.Throwable throwable)
      Logs the specified error message and the accompanying exception.
      void fatalError​(java.lang.String message)
      Logs the specified fatal error message.
      void fatalError​(java.lang.String message, java.lang.Throwable throwable)
      Logs the specified fatal error message and the accompanying exception.
      int getThreshold()
      Getter for the field threshold.
      void info​(java.lang.String message)
      Logs the specified info message.
      void info​(java.lang.String message, java.lang.Throwable throwable)
      Logs the specified info message and the accompanying exception.
      boolean isDebugEnabled()
      isDebugEnabled.
      boolean isErrorEnabled()
      isErrorEnabled.
      boolean isFatalErrorEnabled()
      isFatalErrorEnabled.
      boolean isInfoEnabled()
      isInfoEnabled.
      boolean isWarnEnabled()
      isWarnEnabled.
      private void log​(int level, java.lang.String message, java.lang.Throwable error)
      Writes the specified message and exception to the print stream.
      void setThreshold​(int threshold)
      Sets the logger's threshold.
      void warn​(java.lang.String message)
      Logs the specified warning message.
      void warn​(java.lang.String message, java.lang.Throwable throwable)
      Logs the specified warning message and the accompanying exception.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • out

        private java.io.PrintStream out
        The print stream to write to, never null.
      • threshold

        private int threshold
        The threshold used to filter messages.
    • Constructor Detail

      • PrintStreamLogger

        public PrintStreamLogger()
        Creates a new logger that writes to System.out and has a threshold of InvokerLogger.INFO.
      • PrintStreamLogger

        public PrintStreamLogger​(java.io.PrintStream out,
                                 int threshold)
        Creates a new logger that writes to the specified print stream.
        Parameters:
        out - The print stream to write to, must not be null.
        threshold - The threshold for the logger.
    • Method Detail

      • log

        private void log​(int level,
                         java.lang.String message,
                         java.lang.Throwable error)
        Writes the specified message and exception to the print stream.
        Parameters:
        level - The priority level of the message.
        message - The message to log, may be null.
        error - The exception to log, may be null.
      • debug

        public void debug​(java.lang.String message)
        Logs the specified debug message.
        Specified by:
        debug in interface InvokerLogger
        Parameters:
        message - The message to log, may be null.
      • debug

        public void debug​(java.lang.String message,
                          java.lang.Throwable throwable)
        Logs the specified debug message and the accompanying exception.
        Specified by:
        debug in interface InvokerLogger
        Parameters:
        message - The message to log, may be null.
        throwable - The exception to log, may be null.
      • info

        public void info​(java.lang.String message)
        Logs the specified info message.
        Specified by:
        info in interface InvokerLogger
        Parameters:
        message - The message to log, may be null.
      • info

        public void info​(java.lang.String message,
                         java.lang.Throwable throwable)
        Logs the specified info message and the accompanying exception.
        Specified by:
        info in interface InvokerLogger
        Parameters:
        message - The message to log, may be null.
        throwable - The exception to log, may be null.
      • warn

        public void warn​(java.lang.String message)
        Logs the specified warning message.
        Specified by:
        warn in interface InvokerLogger
        Parameters:
        message - The message to log, may be null.
      • warn

        public void warn​(java.lang.String message,
                         java.lang.Throwable throwable)
        Logs the specified warning message and the accompanying exception.
        Specified by:
        warn in interface InvokerLogger
        Parameters:
        message - The message to log, may be null.
        throwable - The exception to log, may be null.
      • error

        public void error​(java.lang.String message)
        Logs the specified error message.
        Specified by:
        error in interface InvokerLogger
        Parameters:
        message - The message to log, may be null.
      • error

        public void error​(java.lang.String message,
                          java.lang.Throwable throwable)
        Logs the specified error message and the accompanying exception.
        Specified by:
        error in interface InvokerLogger
        Parameters:
        message - The message to log, may be null.
        throwable - The exception to log, may be null.
      • fatalError

        public void fatalError​(java.lang.String message)
        Logs the specified fatal error message.
        Specified by:
        fatalError in interface InvokerLogger
        Parameters:
        message - The message to log, may be null.
      • fatalError

        public void fatalError​(java.lang.String message,
                               java.lang.Throwable throwable)
        Logs the specified fatal error message and the accompanying exception.
        Specified by:
        fatalError in interface InvokerLogger
        Parameters:
        message - The message to log, may be null.
        throwable - The exception to log, may be null.
      • isDebugEnabled

        public boolean isDebugEnabled()

        isDebugEnabled.

        Specified by:
        isDebugEnabled in interface InvokerLogger
        Returns:
        a boolean.
      • isErrorEnabled

        public boolean isErrorEnabled()

        isErrorEnabled.

        Specified by:
        isErrorEnabled in interface InvokerLogger
        Returns:
        a boolean.
      • isFatalErrorEnabled

        public boolean isFatalErrorEnabled()

        isFatalErrorEnabled.

        Specified by:
        isFatalErrorEnabled in interface InvokerLogger
        Returns:
        a boolean.
      • isInfoEnabled

        public boolean isInfoEnabled()

        isInfoEnabled.

        Specified by:
        isInfoEnabled in interface InvokerLogger
        Returns:
        a boolean.
      • isWarnEnabled

        public boolean isWarnEnabled()

        isWarnEnabled.

        Specified by:
        isWarnEnabled in interface InvokerLogger
        Returns:
        a boolean.
      • getThreshold

        public int getThreshold()

        Getter for the field threshold.

        Specified by:
        getThreshold in interface InvokerLogger
        Returns:
        a int.