Class AbstractLogger

  • All Implemented Interfaces:
    java.lang.AutoCloseable, java.lang.Runnable
    Direct Known Subclasses:
    ObjectRecorder, SequenceGrapher

    public abstract class AbstractLogger
    extends java.lang.Thread
    implements java.lang.AutoCloseable
    This is a common super class for all classes which do a kind of logging. It provides an OutputStream and guarantees that this stream is closed at least at shutdown.
    Since:
    1.3.1 (07.09.2013)
    Author:
    oliver
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.lang.Thread

        java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
    • Field Summary

      • Fields inherited from class java.lang.Thread

        MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AbstractLogger​(java.io.OutputStream ostream)
      Instantiates a new abstract logger.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Closes the stream with the logged objects.
      protected static java.io.File createTempLogFile​(java.lang.String prefix, java.lang.String suffix)
      Creates a file in the temp directory.
      protected java.io.OutputStream getLogStream()
      Gets the log stream.
      void run()
      This method is called at shutdown to close the open stream.
      java.lang.String toString()
      To string.
      • Methods inherited from class java.lang.Thread

        activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, yield
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • AbstractLogger

        protected AbstractLogger​(java.io.OutputStream ostream)
        Instantiates a new abstract logger.
        Parameters:
        ostream - the ostream
    • Method Detail

      • createTempLogFile

        protected static java.io.File createTempLogFile​(java.lang.String prefix,
                                                        java.lang.String suffix)
        Creates a file in the temp directory. If this was not successful a file prefix + suffix is returned as result.
        Parameters:
        prefix - the prefix
        suffix - the suffix
        Returns:
        the file
      • getLogStream

        protected final java.io.OutputStream getLogStream()
        Gets the log stream.
        Returns:
        the logStream
      • run

        public void run()
        This method is called at shutdown to close the open stream. Otherwise the closing "</object-stream>" tag in the generated file would be missing (it is generated by the used XStream library).
        Specified by:
        run in interface java.lang.Runnable
        Overrides:
        run in class java.lang.Thread
        See Also:
        Thread.run()
      • close

        public void close()
        Closes the stream with the logged objects.
        Specified by:
        close in interface java.lang.AutoCloseable
      • toString

        public java.lang.String toString()
        To string.
        Overrides:
        toString in class java.lang.Thread
        Returns:
        the string
        See Also:
        Object.toString()