cz.cuni.pogamut.experiments
Class LogFileStorage
java.lang.Object
cz.cuni.pogamut.experiments.LogFileStorage
- All Implemented Interfaces:
- java.io.Serializable
public class LogFileStorage
- extends java.lang.Object
- implements java.io.Serializable
Stores messages from a log in a temporary file. Content of the file can be
loaded into string by the getLogString() method. Typical use case:
LogFileStorage log = new LogFileStorage(bot.getLogger());
...
log.close();
System.out.print(log.getLogString());
- See Also:
- Serialized Form
Field Summary |
(package private) java.io.File |
fileCache
|
(package private) java.util.logging.StreamHandler |
handler
|
(package private) java.lang.String |
logString
|
Constructor Summary |
LogFileStorage(java.util.logging.Logger logger)
Creates new instance of the LogFileStorage. |
Method Summary |
void |
close()
Stops saving log messages into the temp file. |
java.lang.String |
getLogString()
|
protected void |
init(java.util.logging.Logger logger,
java.util.logging.Formatter formatter)
|
protected void |
loadLogToStr()
|
private void |
writeObject(java.io.ObjectOutputStream out)
Stops recording before serialization. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
fileCache
transient java.io.File fileCache
handler
transient java.util.logging.StreamHandler handler
logString
java.lang.String logString
LogFileStorage
public LogFileStorage(java.util.logging.Logger logger)
throws java.io.IOException
- Creates new instance of the LogFileStorage.
- Parameters:
logger
- Logger whose messages will be stored
- Throws:
java.io.IOException
- temporary file couldn't be created
init
protected void init(java.util.logging.Logger logger,
java.util.logging.Formatter formatter)
throws java.io.IOException
- Throws:
java.io.IOException
close
public void close()
- Stops saving log messages into the temp file.
loadLogToStr
protected void loadLogToStr()
getLogString
public java.lang.String getLogString()
- Returns:
- String with all log messages loaded from the temp file.
writeObject
private void writeObject(java.io.ObjectOutputStream out)
throws java.io.IOException
- Stops recording before serialization.
- Parameters:
out
-
- Throws:
java.io.IOException