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 voidclose()Close the underlyingPrintWriter.voidconfigure(java.io.OutputStream stream, int threshold)Configure the loggervoidconfigure(java.lang.String logfile, int threshold)Configure the loggervoidconfigureOrQuit(java.lang.String file, int threshold)Configure the logger or quit if the file cannot be opened for writing.voidconfigureOrQuit(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 voidmain(java.lang.String[] args)static LogmakeLogOrQuit(java.lang.String file, int threshold)Try to create aLogattached to the specified file.static LogmakeLogOrQuit(java.lang.String file, int threshold, java.io.PrintStream error, int exitValue)Try to create aLogattached to the specified file.voidsetOutput(java.io.OutputStream stream)Specifies the stream to which to write the logging messages.voidsetOutput(java.lang.String filename)Specifies the file to which to write the logging messagesvoidsetOutputOrQuit(java.lang.String file)Specifies the file to which to write the logging messages or quit if the file is not writable.voidsetOutputOrQuit(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 leastdebugLevelare 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 leastdebugLevelare logged.)- Throws:
java.io.FileNotFoundException- iflogfilecan't be written to
-
Log
public Log(java.io.OutputStream stream, int threshold)Constructor- Parameters:
stream-OutputStreamto which to write the log datathreshold- Minimum level of importance to be logged. (In other words, only messages with values at leastdebugLevelare 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- iflogfilecan'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- theOutputStreamto which to write logging messages.threshold- Minimum level of importance to be logged. (In other words, only messages with values at leastthresholdare 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 leastthresholdare logged.)- Throws:
java.io.FileNotFoundException- iflogfilecannot 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 leastthresholdare 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 leastthresholdare logged.)
-
makeLogOrQuit
public static Log makeLogOrQuit(java.lang.String file, int threshold, java.io.PrintStream error, int exitValue)Try to create aLogattached 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 leastthesholdare logged.)error- the stream to which to write error messagesexitValue- exit value for process should log creation fail- Returns:
- a valid
Logobject
-
makeLogOrQuit
Try to create aLogattached 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 leastdebugLevelare logged.)- Returns:
- a valid
Logobject
-
close
public void close()Close the underlyingPrintWriter. -
main
public static void main(java.lang.String[] args)
-