Package ec.util
Class Log
java.lang.Object
ec.util.Log
- All Implemented Interfaces:
Serializable
Defines a log to which Output outputs.
Logs can be restarted after a computer outage by using the
information stored in the LogRestarter
restarter.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionboolean
If the log writes to a file, should it append to the file on restart, or should it overwrite the file?static final int
Specifies that the log should write to stderr (System.err)static final int
Specifies that the log should write to stdout (System.out)A filename, if the writer writes to a fileboolean
boolean
Should the log post announcements?boolean
Should the log repost all announcements on restartThe log's restarterboolean
Should we write to this log at all?The log's writer -
Constructor Summary
ConstructorDescriptionLog
(int descriptor, boolean _postAnnouncements) Creates a log on stdout (descriptor == Log.D_STDOUT) or stderr (descriptor == Log.D_STDERR).Creates a log to a given filename; this file may or may not be appended to on restart, depending on _appendOnRestart.Creates a log to a given filename; this file may or may not be appended to on restart, depending on _appendOnRestart.Log
(Writer _writer, LogRestarter _restarter, boolean _postAnnouncements, boolean _repostAnnouncementsOnRestart) Creates a log on a given Writer and custom LogRestarter. -
Method Summary
-
Field Details
-
silent
public boolean silentShould we write to this log at all? -
writer
The log's writer -
filename
A filename, if the writer writes to a file -
postAnnouncements
public boolean postAnnouncementsShould the log post announcements? -
restarter
The log's restarter -
repostAnnouncementsOnRestart
public boolean repostAnnouncementsOnRestartShould the log repost all announcements on restart -
appendOnRestart
public boolean appendOnRestartIf the log writes to a file, should it append to the file on restart, or should it overwrite the file? -
isLoggingToSystemOut
public boolean isLoggingToSystemOut -
D_STDOUT
public static final int D_STDOUTSpecifies that the log should write to stdout (System.out)- See Also:
-
D_STDERR
public static final int D_STDERRSpecifies that the log should write to stderr (System.err)- See Also:
-
-
Constructor Details
-
Log
Creates a log to a given filename; this file may or may not be appended to on restart, depending on _appendOnRestart. If and only if the file is not appended to on restart, then announcements are reposted on restart.- Throws:
IOException
-
Log
public Log(File _filename, boolean _postAnnouncements, boolean _appendOnRestart, boolean gzip) throws IOException Creates a log to a given filename; this file may or may not be appended to on restart, depending on _appendOnRestart. If and only if the file is not appended to on restart, then announcements are reposted on restart. The file can be compressed with gzip, but you may not both gzip AND appendOnRestart. If gzipped, then .gz is automagically appended to the file name.- Throws:
IOException
-
Log
public Log(int descriptor, boolean _postAnnouncements) Creates a log on stdout (descriptor == Log.D_STDOUT) or stderr (descriptor == Log.D_STDERR). -
Log
public Log(Writer _writer, LogRestarter _restarter, boolean _postAnnouncements, boolean _repostAnnouncementsOnRestart) Creates a log on a given Writer and custom LogRestarter. In general, You should not use this to write to a file. Use Log(_filename... instead.
-
-
Method Details
-
restart
Restarts a log after a system restart from checkpoint. Returns the restarted log -- note that it may not be the same log!- Throws:
IOException
-
reopen
Forces a file-based log to reopen, erasing its previous contents. non-file logs ignore this.- Throws:
IOException
-