public class AndHowLogHandler extends Handler
| Modifier and Type | Field and Description |
|---|---|
static String |
MANDATORY_NOTE_PREFIX
Messages beginning with this prefix are important for users to see, but not an error.
|
| Constructor and Description |
|---|
AndHowLogHandler() |
AndHowLogHandler(PrintStream errStream,
PrintStream outStream) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
flush() |
PrintStream |
getErrStream()
Returns the PrintStream used for error level logging (java.util.logging SEVERE level).
|
PrintStream |
getNonErrStream()
Returns the PrintStream used for non-error level logging (java.util.logging WARNING and lower).
|
protected void |
killStream(PrintStream printStream)
Kills a PrintStream, first ensuring that it is not currently assigned to
System.out or System.err.
|
void |
publish(LogRecord record)
Publish a message to either System.out or System.err based on the message Level.
|
protected void |
publishMandatoryNote(LogRecord record)
Publish a message that must be seen, but is not an error.
|
void |
setErrStream(PrintStream errStream)
Sets the PrintStream used for error level logging (java.util.logging SEVERE level).
|
void |
setNonErrStream(PrintStream outStream)
Sets the PrintStream used for non-error level logging (java.util.logging WARNING and lower).
|
getEncoding, getErrorManager, getFilter, getFormatter, getLevel, isLoggable, reportError, setEncoding, setErrorManager, setFilter, setFormatter, setLevelpublic static final String MANDATORY_NOTE_PREFIX
public AndHowLogHandler()
public AndHowLogHandler(PrintStream errStream, PrintStream outStream)
public PrintStream getErrStream()
public void setErrStream(PrintStream errStream)
Setting to null will revert to the default error stream, which is System.err.
errStream - public PrintStream getNonErrStream()
public void setNonErrStream(PrintStream outStream)
Setting to null will revert to the default non-error stream, which is System.out.
outStream - protected void publishMandatoryNote(LogRecord record)
This was created for the case where sample configuration is written to a tmp directory, possibly at the user's request. The message must be displayed or the user will not know where samples were written, but it should not look like an error.
Detection is be done by prefixing the message template text with MANDATORY_NOTE_PREFIX -
this method assumes that detection has already been done. This method will remove
MANDATORY_NOTE_PREFIX anywhere it is found in the message string template.
record - The mandatory note to publish to System.out or System.errpublic void publish(LogRecord record)
Message templates prefixed with MANDATORY_NOTE_PREFIX are passed directly to
publishMandatoryNote(LogRecord). This is done before applying formatting.
public void close()
throws SecurityException
close in class HandlerSecurityExceptionprotected void killStream(PrintStream printStream)
printStream - Copyright © 2022. All rights reserved.