com.parabon.ec.logging
Class LoggerOutput

java.lang.Object
  extended by com.parabon.ec.logging.LoggerOutput
All Implemented Interfaces:
IOutput, java.io.Serializable

public class LoggerOutput
extends java.lang.Object
implements IOutput, java.io.Serializable

Drop-in replacement for Output that uses Log4j for logging.

See Also:
Serialized Form

Field Summary
 
Fields inherited from interface ec.util.IOutput
ALL_LOGS, V_NO_ERRORS, V_NO_GENERAL, V_NO_MESSAGES, V_NO_WARNINGS, V_TOTALLY_SILENT, V_VERBOSE
 
Constructor Summary
LoggerOutput()
          Constructs the logger.
 
Method Summary
 int addLog(java.io.File outputFile, int verbosity, boolean postAnnouncements, boolean appendOnRestart)
          Creates a new log of minimal verbosity verbosity and adds it to Output.
 int addLog(java.io.File outputFile, int verbosity, boolean postAnnouncements, boolean appendOnRestart, boolean gzip)
          Creates a log based on a file pathname.
 int addLog(int descriptor, int verbosity, boolean postAnnouncements)
          Creates a log writing to stderr or stdout.
 void clearAnnouncements()
          Ignored for log4j loggers.
 void clearErrors()
          Clears the fatal error flag.
 void close()
          Closes all output logs.
 void error(java.lang.String s)
          Logs error message to root logger.
 void error(java.lang.String s, Parameter p1)
          Posts a simple error.
 void error(java.lang.String s, Parameter p1, Parameter p2)
          Posts a simple error.
 void exitIfErrors()
          Throws a runtime exception if a fatal error has been logged.
 void fatal(java.lang.String s)
          Posts a fatal error.
 void fatal(java.lang.String s, Parameter p1)
          Posts a fatal error.
 void fatal(java.lang.String s, Parameter p1, Parameter p2)
          Logs a fatal error.
 void flush()
          Flushes the logs
protected  java.lang.String formatMessage(java.lang.String msg, Parameter p1, Parameter p2)
          Formats a log message.
 int getVerbosity()
          Gets global verbosity level.
 void message(java.lang.String s)
          Posts a message.
 void print(java.lang.String s, int verbosity, int logno)
          Appends text to the current log message.
 void print(java.lang.String s, int verbosity, int[] _logs)
          Prints a non-announcement message to the given logs, with a certain verbosity.
 void println(java.lang.String s, int verbosity, int logno)
          Prints a non-announcement message to the given logs, with a certain verbosity.
 void println(java.lang.String s, int verbosity, int[] logs)
          Prints a non-announcement message to the given logs, with a certain verbosity.
 void println(java.lang.String s, int verbosity, int logno, boolean announcement)
          Prints a message to a given log, with a certain verbosity.
 void restart()
           
 void setFilePrefix(java.lang.String filePrefix)
          No-op
 boolean setFlush(boolean v)
          No-op.
 int setVerbosity(int v)
          Sets global verbosity level.
static org.apache.log4j.Level severityLevel(int severity)
          Maps an integer severity code to a Log4j level.
 void systemMessage(java.lang.String s)
          Posts a system message.
 void warning(java.lang.String s)
          Posts a warning.
 void warning(java.lang.String s, Parameter p1)
          Posts a warning.
 void warning(java.lang.String s, Parameter p1, Parameter p2)
          Posts a warning.
 void warnOnce(java.lang.String s)
          Posts a warning one time only.
 void warnOnce(java.lang.String s, Parameter p1)
           
 void warnOnce(java.lang.String s, Parameter p1, Parameter p2)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LoggerOutput

public LoggerOutput()
Constructs the logger.

Method Detail

setFlush

public boolean setFlush(boolean v)
No-op. Flushing is not manually controlled.

Specified by:
setFlush in interface IOutput
Parameters:
v - Value to set flush option to
Returns:
false.

getVerbosity

public int getVerbosity()
Gets global verbosity level.

Specified by:
getVerbosity in interface IOutput

setVerbosity

public int setVerbosity(int v)
Sets global verbosity level.

Specified by:
setVerbosity in interface IOutput
Parameters:
v - ECJ verbosity level

setFilePrefix

public void setFilePrefix(java.lang.String filePrefix)
No-op

Specified by:
setFilePrefix in interface IOutput

addLog

public int addLog(java.io.File outputFile,
                  int verbosity,
                  boolean postAnnouncements,
                  boolean appendOnRestart,
                  boolean gzip)
           throws java.io.IOException
Creates a log based on a file pathname.

Specified by:
addLog in interface IOutput
Parameters:
outputFile - File used for pathname. The file referenced by the pathname need not exist.
verbosity - Log verbosity level.
postAnnouncements - true if announcements are written to log.
appendOnRestart - Ignored for log4j loggers.
gzip - Gzip output stream as it's written.
Throws:
java.io.IOException

addLog

public int addLog(java.io.File outputFile,
                  int verbosity,
                  boolean postAnnouncements,
                  boolean appendOnRestart)
           throws java.io.IOException
Description copied from interface: IOutput
Creates a new log of minimal verbosity verbosity and adds it to Output. This log will write to the file filename, and may or may not post announcements to the log. If the log must be reset upon restarting from a checkpoint, it will append to the file or erase the file and start over depending on appendOnRestart. If appendOnRestart is false and postAnnouncements is true, then this log will repost all the announcements on restarting from a checkpoint. Returns the position of the log in Output's collection of logs -- you should use this to access the log always; never store the log itself, which may go away upon a system restart.

Specified by:
addLog in interface IOutput
Throws:
java.io.IOException

addLog

public int addLog(int descriptor,
                  int verbosity,
                  boolean postAnnouncements)
Creates a log writing to stderr or stdout.

Specified by:
addLog in interface IOutput
Parameters:
descriptor - ECJ log descriptor.
verbosity - Log verbosity level
postAnnouncements - true if announcements are posted to this log.
Returns:
Log number

clearAnnouncements

public void clearAnnouncements()
Ignored for log4j loggers.

Specified by:
clearAnnouncements in interface IOutput

clearErrors

public void clearErrors()
Clears the fatal error flag.

Specified by:
clearErrors in interface IOutput

close

public void close()
Closes all output logs.

Specified by:
close in interface IOutput

flush

public void flush()
Description copied from interface: IOutput
Flushes the logs

Specified by:
flush in interface IOutput

restart

public void restart()
Specified by:
restart in interface IOutput

error

public void error(java.lang.String s)
Logs error message to root logger.

Specified by:
error in interface IOutput
Parameters:
s - Error message

error

public void error(java.lang.String s,
                  Parameter p1)
Description copied from interface: IOutput
Posts a simple error. This causes the error flag to be raised as well.

Specified by:
error in interface IOutput

error

public void error(java.lang.String s,
                  Parameter p1,
                  Parameter p2)
Description copied from interface: IOutput
Posts a simple error. This causes the error flag to be raised as well.

Specified by:
error in interface IOutput

exitIfErrors

public void exitIfErrors()
Throws a runtime exception if a fatal error has been logged.

Specified by:
exitIfErrors in interface IOutput

fatal

public void fatal(java.lang.String s)
Description copied from interface: IOutput
Posts a fatal error. This causes the system to exit.

Specified by:
fatal in interface IOutput

fatal

public void fatal(java.lang.String s,
                  Parameter p1)
Description copied from interface: IOutput
Posts a fatal error. This causes the system to exit.

Specified by:
fatal in interface IOutput

fatal

public void fatal(java.lang.String s,
                  Parameter p1,
                  Parameter p2)
Logs a fatal error.

Specified by:
fatal in interface IOutput
Parameters:
s - Error message
p1 - Parameter error is associated with. May be null.
p2 - Default parameter error is associated with. May be null.

warning

public void warning(java.lang.String s)
Description copied from interface: IOutput
Posts a warning.

Specified by:
warning in interface IOutput

warning

public void warning(java.lang.String s,
                    Parameter p1)
Description copied from interface: IOutput
Posts a warning.

Specified by:
warning in interface IOutput

warning

public void warning(java.lang.String s,
                    Parameter p1,
                    Parameter p2)
Description copied from interface: IOutput
Posts a warning.

Specified by:
warning in interface IOutput

warnOnce

public void warnOnce(java.lang.String s)
Description copied from interface: IOutput
Posts a warning one time only.

Specified by:
warnOnce in interface IOutput

warnOnce

public void warnOnce(java.lang.String s,
                     Parameter p1)
Specified by:
warnOnce in interface IOutput

warnOnce

public void warnOnce(java.lang.String s,
                     Parameter p1,
                     Parameter p2)
Specified by:
warnOnce in interface IOutput

systemMessage

public void systemMessage(java.lang.String s)
Description copied from interface: IOutput
Posts a system message.

Specified by:
systemMessage in interface IOutput

message

public void message(java.lang.String s)
Description copied from interface: IOutput
Posts a message.

Specified by:
message in interface IOutput

print

public void print(java.lang.String s,
                  int verbosity,
                  int logno)
Appends text to the current log message.

Specified by:
print in interface IOutput
Parameters:
s - Log text
verbosity - Verbosity level
logno - Log index

print

public void print(java.lang.String s,
                  int verbosity,
                  int[] _logs)
Description copied from interface: IOutput
Prints a non-announcement message to the given logs, with a certain verbosity. No '\n' is printed.

Specified by:
print in interface IOutput

println

public void println(java.lang.String s,
                    int verbosity,
                    int logno,
                    boolean announcement)
Description copied from interface: IOutput
Prints a message to a given log, with a certain verbosity. If log==ALL_LOGS, posted to all logs.

Specified by:
println in interface IOutput

println

public void println(java.lang.String s,
                    int verbosity,
                    int logno)
Description copied from interface: IOutput
Prints a non-announcement message to the given logs, with a certain verbosity.

Specified by:
println in interface IOutput

println

public void println(java.lang.String s,
                    int verbosity,
                    int[] logs)
Description copied from interface: IOutput
Prints a non-announcement message to the given logs, with a certain verbosity.

Specified by:
println in interface IOutput

formatMessage

protected java.lang.String formatMessage(java.lang.String msg,
                                         Parameter p1,
                                         Parameter p2)
Formats a log message.

Parameters:
msg - Message text
p1 - First parameter being logged. May be null.
p2 - Second parameter being logged. May be null.
Returns:
Log message string

severityLevel

public static org.apache.log4j.Level severityLevel(int severity)
Maps an integer severity code to a Log4j level.

Parameters:
severity - Severity code