Class LoggingPrintStream

    • Field Detail

      • THROWABLE_PREFIX

        public static final String THROWABLE_PREFIX
        The prefix used for "throwable" messages.
        See Also:
        Constant Field Values
      • NORMAL_SEPARATOR

        public static final String NORMAL_SEPARATOR
        The string used to separate the stream name from the message for "normal" messages.
        See Also:
        Constant Field Values
      • LOG_SUBSTITUTION

        public static final String LOG_SUBSTITUTION
        The log string used to identify substitutions.
        See Also:
        Constant Field Values
      • THROWABLE_LOG_FORMAT

        public static final String THROWABLE_LOG_FORMAT
        The log format used for "throwable" messages.
        See Also:
        Constant Field Values
      • NORMAL_LOG_FORMAT

        public static final String NORMAL_LOG_FORMAT
        The log format used for "normal" messages.
        See Also:
        Constant Field Values
    • Constructor Detail

      • LoggingPrintStream

        public LoggingPrintStream​(OutputStream outputStream,
                                  String streamName,
                                  org.slf4j.Logger logger,
                                  org.slf4j.event.Level level,
                                  long closeWaitTime,
                                  TimeUnit closeWaitTimeUnit)
        Constructs a custom PrintStream that logs anything it receives.
        Parameters:
        outputStream - where the received data is to be written.
        streamName - the name of the outputStream to be included in the log messages.
        logger - that is to be used to log the messages.
        level - the logging level to use for log statements.
        closeWaitTime - the time to wait for logging tasks to finish when closing.
        closeWaitTimeUnit - the time unit to use for the closeWaitTime.
    • Method Detail

      • print

        public void print​(String string)
        Prints a string. If the argument is null then the string "null" is printed. Otherwise, the string's characters are converted into bytes according to the character encoding given to the constructor, or the platform's default character encoding if none specified. These bytes are written in exactly the manner of the PrintStream.write(int) method.
        Overrides:
        print in class PrintStream
        Parameters:
        string - The String to be printed
      • println

        public void println​(Object object)
        Prints an Object and then terminate the line. This method calls at first String.valueOf(x) to get the printed object's string value, then behaves as though it invokes print(String) and then PrintStream.println().
        Overrides:
        println in class PrintStream
        Parameters:
        object - The Object to be printed.