
org.refcodes.logger.alt.console.impls.ConsoleLoggerSingleton Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of refcodes-logger-alt-console Show documentation
Show all versions of refcodes-logger-alt-console Show documentation
Artifact for console (terminal) based logging with the refoces logger framework.
// /////////////////////////////////////////////////////////////////////////////
// REFCODES.ORG
// =============================================================================
// This code is copyright (c) by Siegfried Steiner, Munich, Germany and licensed
// under the following (see "http://en.wikipedia.org/wiki/Multi-licensing")
// licenses:
// =============================================================================
// GNU General Public License, v3.0 ("http://www.gnu.org/licenses/gpl-3.0.html")
// together with the GPL linking exception applied; as being applied by the GNU
// Classpath ("http://www.gnu.org/software/classpath/license.html")
// =============================================================================
// Apache License, v2.0 ("http://www.apache.org/licenses/LICENSE-2.0")
// =============================================================================
// Please contact the copyright holding author(s) of the software artifacts in
// question for licensing issues not being covered by the above listed licenses,
// also regarding commercial licensing models or regarding the compatibility
// with other open source licenses.
// /////////////////////////////////////////////////////////////////////////////
package org.refcodes.logger.alt.console.impls;
import java.io.PrintStream;
import org.refcodes.logger.IllegalRecordRuntimeException;
import org.refcodes.logger.Logger;
import org.refcodes.logger.LoggerInstantiationRuntimeException;
import org.refcodes.logger.RuntimeLogger;
import org.refcodes.logger.UnexpectedLogRuntimeException;
import org.refcodes.logger.alt.console.ConsoleLogger;
import org.refcodes.tabular.Record;
import org.refcodes.textual.TableStyle;
/**
* This {@link ConsoleLoggerSingleton} provides a {@link ConsoleLoggerImpl}
* singleton .
*/
@SuppressWarnings("rawtypes")
public class ConsoleLoggerSingleton implements ConsoleLogger {
// /////////////////////////////////////////////////////////////////////////
// VARIABLES:
// /////////////////////////////////////////////////////////////////////////
private static ConsoleLoggerImpl> _consoleLoggerSingleton = new ConsoleLoggerImpl<>();
// /////////////////////////////////////////////////////////////////////////
// CONSTRUCTOR:
// /////////////////////////////////////////////////////////////////////////
/**
* Constructor for constructing a pseudo singleton; this constructor is
* public to provide means to some configuration frameworks (such as
* commons-configurations from Apache) for using this
* {@link ConsoleLoggerSingleton} even when not being able to access the
* {@link #getInstance()} method. The instance overhead for providing
* singleton behavior is taken into account.
*/
public ConsoleLoggerSingleton() {}
// /////////////////////////////////////////////////////////////////////////
// SINGLETON:
// /////////////////////////////////////////////////////////////////////////
/**
* Returns the singleton's instance as fabricated by this
* {@link ConsoleLoggerSingleton}.
*
* @return The {@link RuntimeLogger} singleton's instance.
*
* @throws LoggerInstantiationRuntimeException Thrown in case instantiating
* a {@link Logger} ({@link RuntimeLogger}) failed
*/
public static ConsoleLogger> getInstance() throws LoggerInstantiationRuntimeException {
return _consoleLoggerSingleton;
}
// /////////////////////////////////////////////////////////////////////////
// METHODS:
// /////////////////////////////////////////////////////////////////////////
@SuppressWarnings("unchecked")
@Override
public void log( Record aRecord ) throws IllegalRecordRuntimeException, UnexpectedLogRuntimeException {
_consoleLoggerSingleton.log( aRecord );
}
// /////////////////////////////////////////////////////////////////////////
// METHODS:
// /////////////////////////////////////////////////////////////////////////
@Override
public PrintStream getOutStream() {
return _consoleLoggerSingleton.getOutStream();
}
@Override
public void setOutStream( PrintStream aOutStream ) {
_consoleLoggerSingleton.setOutStream( aOutStream );
}
@Override
public PrintStream getErrStream() {
return _consoleLoggerSingleton.getErrStream();
}
@Override
public void setErrStream( PrintStream aErrStream ) {
_consoleLoggerSingleton.setErrStream( aErrStream );
}
@Override
public TableStyle getTableStyle() {
return _consoleLoggerSingleton.getTableStyle();
}
@Override
public void setTableStyle( TableStyle aTableStyle ) {
_consoleLoggerSingleton.setTableStyle( aTableStyle );
}
@Override
public void setTableStyleName( String aTableStyleName ) {
_consoleLoggerSingleton.setTableStyleName( aTableStyleName );
}
@Override
public void setEscCodes( boolean isEscCodesEnabled ) {
_consoleLoggerSingleton.setEscCodes( isEscCodesEnabled );
}
@Override
public boolean hasLeftBorder() {
return _consoleLoggerSingleton.hasLeftBorder();
}
@Override
public void setLeftBorder( boolean hasLeftBorder ) {
_consoleLoggerSingleton.setLeftBorder( hasLeftBorder );
}
@Override
public boolean hasRightBorder() {
return _consoleLoggerSingleton.hasRightBorder();
}
@Override
public void setRightBorder( boolean hasRightBorder ) {
_consoleLoggerSingleton.setRightBorder( hasRightBorder );
}
@Override
public int getRowWidth() {
return _consoleLoggerSingleton.getRowWidth();
}
@Override
public void setRowWidth( int aRowWidth ) {
_consoleLoggerSingleton.setRowWidth( aRowWidth );
}
// @Override
// public void setMemberType( MemberType aMemberType ) {
// _consoleLoggerSingleton.setMemberType( aMemberType );
// }
// @Override
// public void setMemberTypeName( String aMemberType ) {
// _consoleLoggerSingleton.setMemberTypeName( aMemberType );
// }
// /////////////////////////////////////////////////////////////////////////
// BUILDER:
// /////////////////////////////////////////////////////////////////////////
@Override
public ConsoleLoggerSingleton withOutStream( PrintStream aOutStream ) {
_consoleLoggerSingleton.setOutStream( aOutStream );
return this;
}
@Override
public ConsoleLoggerSingleton withErrStream( PrintStream aErrStream ) {
_consoleLoggerSingleton.setErrStream( aErrStream );
return this;
}
@Override
public ConsoleLoggerSingleton withTableStyle( TableStyle aTableStyle ) {
_consoleLoggerSingleton.setTableStyle( aTableStyle );
return this;
}
@Override
public ConsoleLoggerSingleton withEscCodes( boolean isEscCodesEnabled ) {
_consoleLoggerSingleton.setEscCodes( isEscCodesEnabled );
return this;
}
@Override
public ConsoleLoggerSingleton withLeftBorder( boolean hasLeftBorder ) {
_consoleLoggerSingleton.setLeftBorder( hasLeftBorder );
return this;
}
@Override
public ConsoleLoggerSingleton withRightBorder( boolean hasRightBorder ) {
_consoleLoggerSingleton.setRightBorder( hasRightBorder );
return this;
}
@Override
public RowWidthBuilder withRowWidth( int aRowWidth ) {
_consoleLoggerSingleton.withRowWidth( aRowWidth );
return this;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy