Package omero.log
Class LogMessage
- java.lang.Object
-
- java.io.Writer
-
- java.io.PrintWriter
-
- omero.log.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 extendsPrintWriter
to inherit all sort of usefulprint
methods and adds anotherprint
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.
-
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
-
-
-
-
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 classjava.lang.Object
- Returns:
- See above.
-
-