Package omero.log

Class LogMessage

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.Appendable, java.lang.AutoCloseable

    public class LogMessage
    extends java.io.PrintWriter
    Writes a multi-line log message into a single string. This class should be used to write a log message on multiple lines. In fact, writing text that spans multiple lines is a platform-dependent operation. This class conveniently encapsulates this process while providing a platform-independent interface. This class extends PrintWriter to inherit all sort of useful print methods and adds another print method to write a stack trace into the log message.
    Since:
    OME2.2
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String NEW_LINE
      The new line sequence.
      • Fields inherited from class java.io.PrintWriter

        out
      • Fields inherited from class java.io.Writer

        lock
    • Constructor Summary

      Constructors 
      Constructor Description
      LogMessage()
      Creates a new empty message.
      LogMessage​(java.lang.String msg, java.lang.Throwable t)
      Creates a new instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void print​(java.lang.Throwable t)
      Writes a stack trace into this log message.
      java.lang.String toString()
      Returns the current content of the message.
      • Methods inherited from class java.io.PrintWriter

        append, append, append, checkError, clearError, close, flush, format, format, print, print, print, print, print, print, print, print, print, printf, printf, println, println, println, println, println, println, println, println, println, println, setError, write, write, write, write, write
      • Methods inherited from class java.io.Writer

        nullWriter
      • Methods inherited from class java.lang.Object

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

      • NEW_LINE

        public static final java.lang.String NEW_LINE
        The new line sequence. You can use this to write a string that contains multiple lines.
    • Constructor Detail

      • LogMessage

        public LogMessage()
        Creates a new empty message.
      • LogMessage

        public LogMessage​(java.lang.String msg,
                          java.lang.Throwable t)
        Creates a new instance.
        Parameters:
        msg - The message to log.
        t - The error to log.
    • Method Detail

      • print

        public void print​(java.lang.Throwable t)
        Writes a stack trace into this log message. The information from the exception context is extracted and formatted into a diagnostic message, then printed into the log message. This information includes the exception class name, the exception message, a snapshot of the current stack, and the name of the current thread.
        Parameters:
        t - The exception.
      • toString

        public java.lang.String toString()
        Returns the current content of the message. After this call, the current content is flushed. This means that all what has been written so far will be discarded.
        Overrides:
        toString in class java.lang.Object
        Returns:
        See above.