patterntesting.runtime.log
Class AbstractLogger

Package class diagram package AbstractLogger
java.lang.Object
  extended by java.lang.Thread
      extended by patterntesting.runtime.log.AbstractLogger
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
ObjectRecorder, SequenceGrapher

public abstract class AbstractLogger
extends Thread

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
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
protected AbstractLogger(OutputStream ostream)
          Instantiates a new abstract logger.
 
Method Summary
 void close()
          Closes the stream with the logged objects.
protected static File createTempLogFile(String prefix, String suffix)
          Creates a file in the temp directory.
protected  OutputStream getLogStream()
          Gets the log stream.
protected static OutputStream getStreamFor(File logFile)
          Gets the stream for the given log file.
 void run()
          This method is called at shutdown to close the open stream.
 String toString()
          To string.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractLogger

protected AbstractLogger(OutputStream ostream)
Instantiates a new abstract logger.

Parameters:
ostream - the ostream
Method Detail

createTempLogFile

protected static File createTempLogFile(String prefix,
                                        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

getStreamFor

protected static OutputStream getStreamFor(File logFile)
Gets the stream for the given log file. As fallback stdout will be used.

Parameters:
logFile - the log file
Returns:
the stream for

getLogStream

protected final 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 "" tag in the generated file would be missing (it is generated by the used XStream library).

Specified by:
run in interface Runnable
Overrides:
run in class Thread
See Also:
Thread.run()

close

public void close()
Closes the stream with the logged objects.


toString

public String toString()
To string.

Overrides:
toString in class Thread
Returns:
the string
See Also:
Object.toString()


Copyright © 2002–2014 PatternTesting Team. All rights reserved.