T
- The type of the Record
instances managed by the
Logger
.org.refcodes.component.Destroyable
, FormattedLogger<T>
, org.refcodes.logger.Logger<T>
, org.refcodes.mixin.ErrorPrintStreamAccessor
, org.refcodes.mixin.ErrorPrintStreamAccessor.ErrorPrintStreamBuilder<T>
, org.refcodes.mixin.ErrorPrintStreamAccessor.ErrorPrintStreamMutator
, org.refcodes.mixin.ErrorPrintStreamAccessor.ErrorPrintStreamProperty
, org.refcodes.mixin.RowWidthAccessor
, org.refcodes.mixin.RowWidthAccessor.RowWidthBuilder<T>
, org.refcodes.mixin.RowWidthAccessor.RowWidthMutator
, org.refcodes.mixin.RowWidthAccessor.RowWidthProperty
, org.refcodes.mixin.StandardPrintStreamAccessor
, org.refcodes.mixin.StandardPrintStreamAccessor.StandardPrintStreamBuilder<T>
, org.refcodes.mixin.StandardPrintStreamAccessor.StandardPrintStreamMutator
, org.refcodes.mixin.StandardPrintStreamAccessor.StandardPrintStreamProperty
, org.refcodes.textual.TableStyleAccessor
, org.refcodes.textual.TableStyleAccessor.TableStyleBuilder<T>
, org.refcodes.textual.TableStyleAccessor.TableStyleMutator
, org.refcodes.textual.TableStyleAccessor.TableStyleProperty
ConsoleLoggerImpl
public class FormattedLoggerImpl<T> extends Object implements org.refcodes.component.Destroyable, FormattedLogger<T>
FormattedLoggerImpl
implements the Logger
interface for
providing logging functionality with extended pimped console output (via
System.out
and (via sub-classing also System.err
).
The FormattedLoggerImpl
by default uses the most promising width in
characters of the system's terminal in use by calling the method
SystemUtility.toConsoleWidth()
. 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
SystemProperty.CONSOLE_WIDTH
.
You can also use the setRowWidth(int)
or FormattedLogger.withRowWidth(int)
method in order to programmatically set the console's row width.
Modifier and Type | Class | Description |
---|---|---|
static class |
FormattedLoggerImpl.OutputPrintStream |
The Enum OutputPrintStream.
|
org.refcodes.component.Destroyable.DestroyAutomaton
org.refcodes.mixin.ErrorPrintStreamAccessor.ErrorPrintStreamBuilder<B extends org.refcodes.mixin.ErrorPrintStreamAccessor.ErrorPrintStreamBuilder<?>>, org.refcodes.mixin.ErrorPrintStreamAccessor.ErrorPrintStreamMutator, org.refcodes.mixin.ErrorPrintStreamAccessor.ErrorPrintStreamProperty
org.refcodes.mixin.RowWidthAccessor.RowWidthBuilder<B extends org.refcodes.mixin.RowWidthAccessor.RowWidthBuilder<?>>, org.refcodes.mixin.RowWidthAccessor.RowWidthMutator, org.refcodes.mixin.RowWidthAccessor.RowWidthProperty
org.refcodes.mixin.StandardPrintStreamAccessor.StandardPrintStreamBuilder<B extends org.refcodes.mixin.StandardPrintStreamAccessor.StandardPrintStreamBuilder<?>>, org.refcodes.mixin.StandardPrintStreamAccessor.StandardPrintStreamMutator, org.refcodes.mixin.StandardPrintStreamAccessor.StandardPrintStreamProperty
org.refcodes.textual.TableStyleAccessor.TableStyleBuilder<B extends org.refcodes.textual.TableStyleAccessor.TableStyleBuilder<?>>, org.refcodes.textual.TableStyleAccessor.TableStyleMutator, org.refcodes.textual.TableStyleAccessor.TableStyleProperty
Modifier and Type | Field | Description |
---|---|---|
protected PrintStream |
_errStream |
|
protected boolean |
_hasLeftBorder |
|
protected boolean |
_hasRightBorder |
|
protected org.refcodes.tabular.FormattedHeader<T> |
_header |
|
protected int |
_rowWidth |
|
protected PrintStream |
_stdStream |
|
protected org.refcodes.textual.TableBuilder |
_tableBuilder |
|
protected org.refcodes.textual.TableStyle |
_tableStyle |
Constructor | Description |
---|---|
FormattedLoggerImpl(org.refcodes.tabular.FormattedHeader<T> aHeader) |
Initially enables or disables ANSI escape sequences as of detection of
terminal's ANSI support.
|
Modifier and Type | Method | Description |
---|---|---|
void |
destroy() |
|
PrintStream |
getErrorPrintStream() |
|
int |
getRowWidth() |
|
PrintStream |
getStandardPrintStream() |
|
org.refcodes.textual.TableStyle |
getTableStyle() |
|
boolean |
hasEscapeCodes() |
Checks for escape codes.
|
boolean |
hasLeftBorder() |
Checks for left border.
|
boolean |
hasRightBorder() |
Checks for right border.
|
protected void |
init() |
Inits the.
|
void |
log(org.refcodes.tabular.Record<? extends T> aRecord) |
|
protected void |
log(org.refcodes.tabular.Record<? extends T> aRecord,
org.refcodes.tabular.FormattedHeader<T> aHeader,
org.refcodes.textual.TableBuilder aTableBuilder) |
Prints out a log-line with regard to the provided
Header unsing
the provided TableBuilder . |
void |
setErrorPrintStream(PrintStream aErrStream) |
|
void |
setEscapeCodes(boolean isEscCodesEnabled) |
Sets the escape codes.
|
void |
setLeftBorder(boolean hasLeftBorder) |
Sets the left border.
|
void |
setLoggerStyle(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. |
void |
setRightBorder(boolean hasRightBorder) |
Sets the right border.
|
void |
setRowWidth(int aRowWidth) |
|
void |
setStandardPrintStream(PrintStream aOutStream) |
|
void |
setTableStyle(org.refcodes.textual.TableStyle aTableStyle) |
|
protected org.refcodes.textual.TableBuilder |
toPreConfiguredTableBuilder(org.refcodes.tabular.FormattedHeader<?> aHeader,
FormattedLoggerImpl.OutputPrintStream aOutputPrintStream) |
Creates a pre-configured
TableBuilder , can be used by sub-classes
in case them require additional TableBuilder instances. |
withErrorPrintStream, withEscapeCodes, withLeftBorder, withRightBorder, withRowWidth, withStandardPrintStream, withTableStyle
protected org.refcodes.tabular.FormattedHeader<T> _header
protected org.refcodes.textual.TableBuilder _tableBuilder
protected PrintStream _stdStream
protected PrintStream _errStream
protected int _rowWidth
protected org.refcodes.textual.TableStyle _tableStyle
protected boolean _hasLeftBorder
protected boolean _hasRightBorder
public FormattedLoggerImpl(org.refcodes.tabular.FormattedHeader<T> aHeader)
setEscapeCodes(boolean)
.aHeader
- the headerSystemUtility.isAnsiTerminal()
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 getStandardPrintStream()
getStandardPrintStream
in interface org.refcodes.mixin.StandardPrintStreamAccessor
public void setStandardPrintStream(PrintStream aOutStream)
setStandardPrintStream
in interface org.refcodes.mixin.StandardPrintStreamAccessor.StandardPrintStreamMutator
public PrintStream getErrorPrintStream()
getErrorPrintStream
in interface org.refcodes.mixin.ErrorPrintStreamAccessor
public void setErrorPrintStream(PrintStream aErrStream)
setErrorPrintStream
in interface org.refcodes.mixin.ErrorPrintStreamAccessor.ErrorPrintStreamMutator
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 setLoggerStyle(String aTableStyleName)
RuntimeLoggerSingleton
cannot convert a String to an enum, we got
to provide such a method ourselves. When configuring programmatically use
TableStyleAccessor.TableStyleMutator.setTableStyle(TableStyle)
, when using the
"runtimelogger-config.xml
" use the property "loggerStyle"
for this method to be invoked. Valid arguments are as of the
TableStyle
enumeration:
setLoggerStyle
in interface FormattedLogger<T>
aTableStyleName
- The style to use for the logger.public void setEscapeCodes(boolean isEscCodesEnabled)
setEscapeCodes
in interface FormattedLogger<T>
isEscCodesEnabled
- the new escape codespublic boolean hasLeftBorder()
hasLeftBorder
in interface FormattedLogger<T>
public void setLeftBorder(boolean hasLeftBorder)
setLeftBorder
in interface FormattedLogger<T>
hasLeftBorder
- the new left borderpublic boolean hasRightBorder()
hasRightBorder
in interface FormattedLogger<T>
public void setRightBorder(boolean hasRightBorder)
setRightBorder
in interface FormattedLogger<T>
hasRightBorder
- the new right borderpublic int getRowWidth()
getRowWidth
in interface org.refcodes.mixin.RowWidthAccessor
public void setRowWidth(int aRowWidth)
setRowWidth
in interface org.refcodes.mixin.RowWidthAccessor.RowWidthMutator
public boolean hasEscapeCodes()
hasEscapeCodes
in interface FormattedLogger<T>
public void destroy()
destroy
in interface org.refcodes.component.Destroyable
protected void init()
protected org.refcodes.textual.TableBuilder toPreConfiguredTableBuilder(org.refcodes.tabular.FormattedHeader<?> aHeader, FormattedLoggerImpl.OutputPrintStream aOutputPrintStream)
TableBuilder
, can be used by sub-classes
in case them require additional TableBuilder
instances.aHeader
- the headeraOutputPrintStream
- the output print streamTableBuilder
(as of the attributes state
of the FormattedLoggerImpl
).protected void log(org.refcodes.tabular.Record<? extends T> aRecord, org.refcodes.tabular.FormattedHeader<T> aHeader, org.refcodes.textual.TableBuilder aTableBuilder)
Header
unsing
the provided TableBuilder
.aRecord
- The record to log.aHeader
- The Header
with which to determine the visibility
of the Record
's elements.aTableBuilder
- The TableBuilder
to use for printing.ClassCastException
- the class cast exceptionCopyright © 2018. All rights reserved.