Package edu.gvsu.kurmasz.warszawa.log
Class Log
java.lang.Object
edu.gvsu.kurmasz.warszawa.log.SimpleLog
edu.gvsu.kurmasz.warszawa.log.Log
public class Log extends SimpleLog
A
SimpleLog
with extended configurability.- Author:
- Zachary Kurmas
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description void
close()
Close the underlyingPrintWriter
.void
configure(java.io.OutputStream stream, int threshold)
Configure the loggervoid
configure(java.lang.String logfile, int threshold)
Configure the loggervoid
configureOrQuit(java.lang.String file, int threshold)
Configure the logger or quit if the file cannot be opened for writing.void
configureOrQuit(java.lang.String file, int threshold, java.io.PrintStream error, int exitValue)
Configure the logger or quit if the file cannot be opened for writing.static void
main(java.lang.String[] args)
static Log
makeLogOrQuit(java.lang.String file, int threshold)
Try to create aLog
attached to the specified file.static Log
makeLogOrQuit(java.lang.String file, int threshold, java.io.PrintStream error, int exitValue)
Try to create aLog
attached to the specified file.void
setOutput(java.io.OutputStream stream)
Specifies the stream to which to write the logging messages.void
setOutput(java.lang.String filename)
Specifies the file to which to write the logging messagesvoid
setOutputOrQuit(java.lang.String file)
Specifies the file to which to write the logging messages or quit if the file is not writable.void
setOutputOrQuit(java.lang.String filename, java.io.PrintStream error, int exit_value)
Specifies the writer to which to write the logging messages or quit if the file is not writable.Methods inherited from class edu.gvsu.kurmasz.warszawa.log.SimpleLog
configure, println, setOutput, setThreshold, setThresholdToMax, willLog
-
Constructor Details
-
Log
public Log()Constructs a silent log. -
Log
public Log(java.io.PrintWriter log, int threshold)Constructor- Parameters:
log
- where to write the log datathreshold
- Minimum level of importance to be logged. (In other words, only messages with values at leastdebugLevel
are logged.)
-
Log
public Log(java.lang.String logfile, int threshold) throws java.io.FileNotFoundExceptionConstructor- Parameters:
logfile
- where to write the log datathreshold
- Minimum level of importance to be logged. (In other words, only messages with values at leastdebugLevel
are logged.)- Throws:
java.io.FileNotFoundException
- iflogfile
can't be written to
-
Log
public Log(java.io.OutputStream stream, int threshold)Constructor- Parameters:
stream
-OutputStream
to which to write the log datathreshold
- Minimum level of importance to be logged. (In other words, only messages with values at leastdebugLevel
are logged.)
-
-
Method Details
-
setOutput
public void setOutput(java.io.OutputStream stream)Specifies the stream to which to write the logging messages.- Parameters:
stream
- the stream
-
setOutput
public void setOutput(java.lang.String filename) throws java.io.FileNotFoundExceptionSpecifies the file to which to write the logging messages- Parameters:
filename
- the file to which to write logging messages. An empty or null string will deactivate logging.- Throws:
java.io.FileNotFoundException
- iflogfile
can't be written to
-
setOutputOrQuit
public void setOutputOrQuit(java.lang.String filename, java.io.PrintStream error, int exit_value)Specifies the writer to which to write the logging messages or quit if the file is not writable.- Parameters:
filename
- the file to which to write logging messageserror
- the stream to which to write error messagesexit_value
- exit value for process should log creation fail
-
setOutputOrQuit
public void setOutputOrQuit(java.lang.String file)Specifies the file to which to write the logging messages or quit if the file is not writable. (Process exits with a return value of 1.)- Parameters:
file
- the file to which to write logging messages
-
configure
public void configure(java.io.OutputStream stream, int threshold)Configure the logger- Parameters:
stream
- theOutputStream
to which to write logging messages.threshold
- Minimum level of importance to be logged. (In other words, only messages with values at leastthreshold
are logged.)
-
configure
public void configure(java.lang.String logfile, int threshold) throws java.io.FileNotFoundExceptionConfigure the logger- Parameters:
logfile
- the file to which to write logging messages. An empty or null string will deactivate logging.threshold
- Minimum level of importance to be logged. (In other words, only messages with values at leastthreshold
are logged.)- Throws:
java.io.FileNotFoundException
- iflogfile
cannot be opened for writing.
-
configureOrQuit
public void configureOrQuit(java.lang.String file, int threshold, java.io.PrintStream error, int exitValue)Configure the logger or quit if the file cannot be opened for writing.- Parameters:
file
- the file to which to write logging messages. An empty or null string will deactivate logging.threshold
- Minimum level of importance to be logged. (In other words, only messages with values at leastthreshold
are logged.)error
- the stream to which to write error messagesexitValue
- exit value for process should log creation fail
-
configureOrQuit
public void configureOrQuit(java.lang.String file, int threshold)Configure the logger or quit if the file cannot be opened for writing.- Parameters:
file
- the file to which to write logging messages. An empty or null string will deactivate logging.threshold
- Minimum level of importance to be logged. (In other words, only messages with values at leastthreshold
are logged.)
-
makeLogOrQuit
public static Log makeLogOrQuit(java.lang.String file, int threshold, java.io.PrintStream error, int exitValue)Try to create aLog
attached to the specified file. If the file is not writable, print an error message and quit.- Parameters:
file
- the file to which to write logging messagesthreshold
- Minimum level of importance to be logged. (In other words, only messages with values at leasttheshold
are logged.)error
- the stream to which to write error messagesexitValue
- exit value for process should log creation fail- Returns:
- a valid
Log
object
-
makeLogOrQuit
Try to create aLog
attached to the specified file. If the file is not writable, print an error message and quit.- Parameters:
file
- the file to which to write logging messagesthreshold
- Minimum level of importance to be logged. (In other words, only messages with values at leastdebugLevel
are logged.)- Returns:
- a valid
Log
object
-
close
public void close()Close the underlyingPrintWriter
. -
main
public static void main(java.lang.String[] args)
-