T
- The type of the Record
instances managed by the
Logger
.public class ConsoleLoggerImpl<T> extends Object implements org.refcodes.component.Destroyable, ConsoleLogger<T>
ConsoleLoggerImpl
implements the Logger
interface for
providing logging functionality for extended pimped console output (via
System.out
and System.err
to be used by RuntimeLogger
implementations.
ATTENTION: As the table layout for the generated log lines makes only sense
when all ConsoleLoggerImpl
instances print out their output according
to the last state of a previous output (from another instance of the
ConsoleLoggerImpl
), the "bean" attributes refer actually to static
member variables: Their values are valid for all instances of this class!
Still the setters and getters are of "instance" scope (not static) to enable the builder-pattern to be applied.
The ConsoleLoggerImpl
by default uses the
SystemUtility.getConsoleWidth()
method, which determines the width in
characters of the system's console in use. In case you pass a
"-Dconsole.width=n" JVM argument, then your width is taken, else the actual
console's width is being tried to be determined. See
SystemUtility#SYS_PROP_CONSOLE_WIDTH
.
You can also use the setRowWidth(int)
or withRowWidth(int)
method in order to programmatically set the console's row width.
org.refcodes.component.Destroyable.DestroyAutomaton
org.refcodes.mixin.RowWidthAccessor.RowWidthBuilder<B extends org.refcodes.mixin.RowWidthAccessor.RowWidthBuilder<?>>, org.refcodes.mixin.RowWidthAccessor.RowWidthMutator, org.refcodes.mixin.RowWidthAccessor.RowWidthProperty
org.refcodes.textual.TableStyleAccessor.TableStyleBuilder<B extends org.refcodes.textual.TableStyleAccessor.TableStyleBuilder<?>>, org.refcodes.textual.TableStyleAccessor.TableStyleMutator, org.refcodes.textual.TableStyleAccessor.TableStyleProperty
Constructor and Description |
---|
ConsoleLoggerImpl()
Initially enables or disables ANSI escape sequences as of detection of
terminal's ANSI support.
|
Modifier and Type | Method and Description |
---|---|
void |
destroy() |
PrintStream |
getErrStream() |
PrintStream |
getOutStream() |
int |
getRowWidth() |
org.refcodes.textual.TableStyle |
getTableStyle() |
boolean |
hasLeftBorder() |
boolean |
hasRightBorder() |
void |
log(org.refcodes.tabular.Record<? extends T> aRecord) |
void |
setErrStream(PrintStream aErrStream) |
void |
setEscCodes(boolean isEscCodesEnabled) |
void |
setLeftBorder(boolean hasLeftBorder) |
void |
setOutStream(PrintStream aOutStream) |
void |
setRightBorder(boolean hasRightBorder) |
void |
setRowWidth(int aRowWidth) |
void |
setTableStyle(org.refcodes.textual.TableStyle aTableStyle) |
void |
setTableStyleName(String aTableStyleName)
As the underlying configuration framework used by the
RuntimeLoggerSingleton cannot convert a String to an enum, we got
to provide such a method ourselves. |
ConsoleLogger<T> |
withErrStream(PrintStream aErrStream) |
ConsoleLogger<T> |
withEscCodes(boolean isEscCodesEnabled) |
ConsoleLogger<T> |
withLeftBorder(boolean hasLeftBorder) |
ConsoleLogger<T> |
withOutStream(PrintStream aOutStream) |
ConsoleLogger<T> |
withRightBorder(boolean hasRightBorder) |
ConsoleLogger<?> |
withRowWidth(int aRowWidth) |
ConsoleLogger<T> |
withTableStyle(org.refcodes.textual.TableStyle aTableStyle) |
public ConsoleLoggerImpl()
setEscCodes(boolean)
.SystemUtility.isAnsiSupported()
public void log(org.refcodes.tabular.Record<? extends T> aRecord) throws org.refcodes.logger.IllegalRecordRuntimeException, org.refcodes.logger.UnexpectedLogRuntimeException
log
in interface org.refcodes.logger.Logger<T>
org.refcodes.logger.IllegalRecordRuntimeException
org.refcodes.logger.UnexpectedLogRuntimeException
public PrintStream getOutStream()
getOutStream
in interface ConsoleLogger<T>
public void setOutStream(PrintStream aOutStream)
setOutStream
in interface ConsoleLogger<T>
public PrintStream getErrStream()
getErrStream
in interface ConsoleLogger<T>
public void setErrStream(PrintStream aErrStream)
setErrStream
in interface ConsoleLogger<T>
public org.refcodes.textual.TableStyle getTableStyle()
getTableStyle
in interface org.refcodes.textual.TableStyleAccessor
public void setTableStyle(org.refcodes.textual.TableStyle aTableStyle)
setTableStyle
in interface org.refcodes.textual.TableStyleAccessor.TableStyleMutator
public void setTableStyleName(String aTableStyleName)
ConsoleLogger
RuntimeLoggerSingleton
cannot convert a String to an enum, we got
to provide such a method ourselves. When configuring programmatically use
RowWidthAccessor.RowWidthMutator.setRowWidth(int)
or RowWidthAccessor.RowWidthBuilder.withRowWidth(int)
, when using the
"runtimelogger-config.xml" ise the property "tableStyleName" for this
method to be invoked. Valid arguments are as of the TableStyle
enumeration:
setTableStyleName
in interface ConsoleLogger<T>
public void setEscCodes(boolean isEscCodesEnabled)
setEscCodes
in interface ConsoleLogger<T>
public boolean hasLeftBorder()
hasLeftBorder
in interface ConsoleLogger<T>
public void setLeftBorder(boolean hasLeftBorder)
setLeftBorder
in interface ConsoleLogger<T>
public boolean hasRightBorder()
hasRightBorder
in interface ConsoleLogger<T>
public void setRightBorder(boolean hasRightBorder)
setRightBorder
in interface ConsoleLogger<T>
public int getRowWidth()
getRowWidth
in interface org.refcodes.mixin.RowWidthAccessor
public void setRowWidth(int aRowWidth)
setRowWidth
in interface org.refcodes.mixin.RowWidthAccessor.RowWidthMutator
public ConsoleLogger<T> withOutStream(PrintStream aOutStream)
withOutStream
in interface ConsoleLogger<T>
public ConsoleLogger<T> withErrStream(PrintStream aErrStream)
withErrStream
in interface ConsoleLogger<T>
public ConsoleLogger<T> withTableStyle(org.refcodes.textual.TableStyle aTableStyle)
withTableStyle
in interface org.refcodes.textual.TableStyleAccessor.TableStyleBuilder<ConsoleLogger<?>>
public ConsoleLogger<T> withEscCodes(boolean isEscCodesEnabled)
withEscCodes
in interface ConsoleLogger<T>
public ConsoleLogger<T> withLeftBorder(boolean hasLeftBorder)
withLeftBorder
in interface ConsoleLogger<T>
public ConsoleLogger<T> withRightBorder(boolean hasRightBorder)
withRightBorder
in interface ConsoleLogger<T>
public ConsoleLogger<?> withRowWidth(int aRowWidth)
withRowWidth
in interface org.refcodes.mixin.RowWidthAccessor.RowWidthBuilder<ConsoleLogger<?>>
public void destroy()
destroy
in interface org.refcodes.component.Destroyable
Copyright © 2017. All rights reserved.