public class Output extends Object implements Serializable
Outputs and logs system messages, errors, and other various items printed as a result of a run.
Output maintains zero or more logs, which contain Writers which write out stuff. Each log has an associated verbosity; if request is made to write text to a log, and the text's maximal verbosity is lower than the verbosity of the log, the log will not write it. Each Output instance also has an instance-level global verbosity; incoming requests to write text are additionally subject to this verbosity test. Lastly, the Output class itself has a global verbosity as well. This last verbosity is useful for shutting down writing to all logs in the entire system in a simple way.
When the system fails for some reason and must be started back up from a checkpoint, Output's log files may be overwritten. Output offers three approaches here. First, Output can clear the log file and overwrite it. Second, Output can append to the existing log file; because checkpoints are only done occasionally, this may result in duplicate outputs to a file, so keep this in mind. Third, Output can keep certain written text, typically announcements, in memory; this text gets written out into the checkpoint file, and so it is sound.
There are several kinds of announcements, in different levels of importance.
Output will also store all announcements in memory by default so as to reproduce them if it's restarted from a checkpoint. You can change this behavior also by
| Modifier and Type | Class and Description |
|---|---|
(package private) static class |
Output.Announcement |
static class |
Output.OutputExitException |
| Modifier and Type | Field and Description |
|---|---|
static int |
ALL_MESSAGE_LOGS |
(package private) Vector |
announcements |
(package private) StringBuilder |
error |
(package private) boolean |
errors |
(package private) String |
filePrefix |
(package private) Vector |
logs |
static int |
NO_LOGS
When passed to print functions, doesn't do any printing
|
(package private) HashSet |
oneTimeWarnings |
private static long |
serialVersionUID |
(package private) boolean |
store |
(package private) boolean |
throwsErrors |
static int |
V_NO_ERRORS
Don't print warnings, messages, or simple errors
|
static int |
V_NO_GENERAL
The standard verbosity to use if you don't want common reporting (like statistics)
|
static int |
V_NO_MESSAGES
Don't print messages
|
static int |
V_NO_WARNINGS
Don't print warnings or messages
|
static int |
V_TOTALLY_SILENT
No verbosity at all, not even system messages or fatal errors
|
static int |
V_VERBOSE
Total verbosity
|
| Constructor and Description |
|---|
Output(boolean storeAnnouncementsInMemory)
Creates a new, verbose, empty Output object.
|
Output(boolean storeAnnouncementsInMemory,
int _verbosity)
Deprecated.
Verbosity no longer has an effect.
|
| Modifier and Type | Method and Description |
|---|---|
(package private) String |
a(String str) |
int |
addLog(File file,
boolean appendOnRestart)
Creates a new log and adds it
to Output.
|
int |
addLog(File file,
boolean appendOnRestart,
boolean gzip)
Creates a new log and adds it
to Output.
|
int |
addLog(File file,
boolean postAnnouncements,
boolean appendOnRestart,
boolean gzip)
Creates a new log and adds it
to Output.
|
int |
addLog(File file,
int _verbosity,
boolean postAnnouncements,
boolean appendOnRestart)
Deprecated.
Verbosity no longer has an effect
|
int |
addLog(File file,
int _verbosity,
boolean postAnnouncements,
boolean appendOnRestart,
boolean gzip)
Deprecated.
Verbosity no longer has an effect.
|
int |
addLog(int descriptor,
boolean postAnnouncements)
Creates a new log and adds it
to Output.
|
int |
addLog(int descriptor,
int _verbosity,
boolean postAnnouncements)
Deprecated.
Verbosity no longer has an effect
|
int |
addLog(Log l)
Adds the given log to Output.
|
int |
addLog(Writer writer,
LogRestarter restarter,
boolean postAnnouncements,
boolean repostAnnouncements)
Creates a new log and adds it
to Output.
|
int |
addLog(Writer writer,
LogRestarter restarter,
int _verbosity,
boolean postAnnouncements,
boolean repostAnnouncements)
Deprecated.
Verbosity no longer has an effect
|
void |
clearAnnouncements()
Clears out announcements.
|
void |
clearErrors()
Clears the error flag.
|
void |
close()
Closes the logs -- ONLY call this if you are preparing to quit
|
void |
error(String s)
Posts a simple error.
|
void |
error(String s,
Parameter p1)
Posts a simple error.
|
void |
error(String s,
Parameter p1,
Parameter p2)
Posts a simple error.
|
void |
exitIfErrors()
Exits with a fatal error if the error flag has been raised.
|
private static void |
exitWithError(Output output,
String message,
boolean throwException) |
void |
fatal(String s)
Posts a fatal error.
|
void |
fatal(String s,
Parameter p1)
Posts a fatal error.
|
void |
fatal(String s,
Parameter p1,
Parameter p2)
Posts a fatal error.
|
protected void |
finalize() |
void |
flush()
Flushes the logs
|
boolean |
getFlush() |
Log |
getLog(int x)
Returns the given log.
|
boolean |
getStore() |
boolean |
getThrowsErrors() |
int |
getVerbosity()
Deprecated.
Verbosity no longer has an effect.
|
static void |
initialError(String s)
Prints an initial error to System.err.
|
static void |
initialError(String s,
Parameter p1)
Prints an initial error to System.err.
|
static void |
initialError(String s,
Parameter p1,
Parameter p2)
Prints an initial error to System.err.
|
static void |
initialMessage(String s)
Prints an initial message to System.err.
|
static void |
initialWarning(String s)
Prints an initial warning to System.err.
|
static void |
initialWarning(String s,
Parameter p1)
Prints an initial warning to System.err.
|
static void |
initialWarning(String s,
Parameter p1,
Parameter p2)
Prints an initial warning to System.err.
|
static InputStream |
makeCompressingInputStream(InputStream in)
Returns a compressing input stream using JZLib (http://www.jcraft.com/jzlib/).
|
static OutputStream |
makeCompressingOutputStream(OutputStream out)
Returns a compressing output stream using JZLib (http://www.jcraft.com/jzlib/).
|
void |
message(String s)
Posts a message.
|
int |
numLogs()
Returns the number of logs currently posted.
|
void |
print(String s,
int log)
Prints a non-announcement message to a given log.
|
void |
print(String s,
int[] _logs)
Prints a non-announcement message to the given logs,
with a certain verbosity.
|
void |
print(String s,
int _verbosity,
int log)
Prints a non-announcement message to a given log, with a
certain verbosity.
|
void |
print(String s,
int _verbosity,
int[] _logs)
Deprecated.
Verbosity no longer has any effect
|
protected void |
print(String s,
int _verbosity,
Log log)
Prints a non-announcement message to a given log, with a
certain verbosity.
|
void |
println(String s,
int log)
Prints a non-announcement message to the given logs, with a verbosity of V_NO_GENERAL.
|
void |
println(String s,
int log,
boolean _announcement)
Prints a message to a given log.
|
void |
println(String s,
int _verbosity,
int log)
Deprecated.
Verbosity no longer has an effect
|
void |
println(String s,
int _verbosity,
int[] _logs)
Deprecated.
Verbosity no longer has an effect
|
(package private) void |
println(String s,
int _verbosity,
int log,
boolean _announcement)
Deprecated.
Verbosity no longer has an effect
|
(package private) void |
println(String s,
int _verbosity,
Log log,
boolean _announcement,
boolean _reposting)
Deprecated.
Verbosity no longer has an effect
|
Log |
removeLog(int x)
Removes the given log.
|
void |
reopen(int _log)
Forces a file-based log to reopen, erasing its previous contents.
|
void |
reopen(int[] _logs)
Forces one or more file-based logs to reopen, erasing
their previous contents.
|
void |
restart() |
void |
setFilePrefix(String filePrefix) |
void |
setFlush(boolean v)
Deprecated.
We now always flush
|
void |
setStore(boolean v)
Sets whether the Output stores its announcements.
|
void |
setThrowsErrors(boolean val) |
void |
setVerbosity(int v)
Deprecated.
Verbosity no longer has an effect.
|
void |
systemMessage(String s)
Posts a system message.
|
void |
warning(String s)
Posts a warning.
|
void |
warning(String s,
Parameter p1)
Posts a warning.
|
void |
warning(String s,
Parameter p1,
Parameter p2)
Posts a warning.
|
void |
warnOnce(String s)
Posts a warning one time only.
|
void |
warnOnce(String s,
Parameter p1) |
void |
warnOnce(String s,
Parameter p1,
Parameter p2) |
private static final long serialVersionUID
boolean errors
Vector logs
Vector announcements
boolean store
String filePrefix
boolean throwsErrors
public static final int V_VERBOSE
public static final int V_NO_MESSAGES
public static final int V_NO_WARNINGS
public static final int V_NO_GENERAL
public static final int V_NO_ERRORS
public static final int V_TOTALLY_SILENT
public static final int ALL_MESSAGE_LOGS
public static final int NO_LOGS
StringBuilder error
HashSet oneTimeWarnings
public Output(boolean storeAnnouncementsInMemory,
int _verbosity)
public Output(boolean storeAnnouncementsInMemory)
public void setFilePrefix(String filePrefix)
public void setThrowsErrors(boolean val)
public boolean getThrowsErrors()
protected void finalize()
throws Throwable
private static void exitWithError(Output output, String message, boolean throwException)
public void close()
public void flush()
public void setFlush(boolean v)
public boolean getFlush()
public void setStore(boolean v)
public boolean getStore()
public void setVerbosity(int v)
public int getVerbosity()
public int addLog(File file, int _verbosity, boolean postAnnouncements, boolean appendOnRestart, boolean gzip) throws IOException
IOExceptionpublic int addLog(File file, int _verbosity, boolean postAnnouncements, boolean appendOnRestart) throws IOException
IOExceptionpublic int addLog(File file, boolean postAnnouncements, boolean appendOnRestart, boolean gzip) throws IOException
IOExceptionpublic int addLog(File file, boolean appendOnRestart, boolean gzip) throws IOException
IOExceptionpublic int addLog(File file, boolean appendOnRestart) throws IOException
IOExceptionpublic int addLog(int descriptor,
int _verbosity,
boolean postAnnouncements)
public int addLog(int descriptor,
boolean postAnnouncements)
public int addLog(Writer writer, LogRestarter restarter, int _verbosity, boolean postAnnouncements, boolean repostAnnouncements)
public int addLog(Writer writer, LogRestarter restarter, boolean postAnnouncements, boolean repostAnnouncements)
public int addLog(Log l)
public int numLogs()
public Log getLog(int x)
public Log removeLog(int x)
public static void initialWarning(String s)
public static void initialWarning(String s, Parameter p1)
public static void initialWarning(String s, Parameter p1, Parameter p2)
public static void initialError(String s)
public static void initialError(String s, Parameter p1)
public static void initialError(String s, Parameter p1, Parameter p2)
public static void initialMessage(String s)
public void systemMessage(String s)
public void fatal(String s)
public void fatal(String s, Parameter p1)
public void fatal(String s, Parameter p1, Parameter p2)
public void error(String s)
public void error(String s, Parameter p1)
public void error(String s, Parameter p1, Parameter p2)
public void warning(String s)
public void warnOnce(String s)
public void message(String s)
public void reopen(int _log)
throws IOException
IOExceptionpublic void reopen(int[] _logs)
throws IOException
IOExceptionvoid println(String s, int _verbosity, Log log, boolean _announcement, boolean _reposting) throws OutputException
OutputExceptionvoid println(String s, int _verbosity, int log, boolean _announcement) throws OutputException
OutputExceptionpublic void println(String s, int log, boolean _announcement) throws OutputException
OutputExceptionpublic void println(String s, int _verbosity, int[] _logs) throws OutputException
OutputExceptionpublic void println(String s, int _verbosity, int log) throws OutputException
OutputExceptionpublic void println(String s, int log) throws OutputException
OutputExceptionprotected void print(String s, int _verbosity, Log log) throws OutputException
OutputExceptionpublic void print(String s, int _verbosity, int log) throws OutputException
OutputExceptionpublic void print(String s, int log) throws OutputException
OutputExceptionpublic void print(String s, int _verbosity, int[] _logs) throws OutputException
OutputExceptionpublic void print(String s, int[] _logs) throws OutputException
OutputExceptionpublic void exitIfErrors()
public void clearErrors()
public void clearAnnouncements()
public void restart()
throws IOException
IOExceptionpublic static InputStream makeCompressingInputStream(InputStream in)
public static OutputStream makeCompressingOutputStream(OutputStream out)
Copyright © 2014 Evolutionary Computation Laboratory at George Mason University. All rights reserved.