de.esprit.common.log

## Class AbstractLogPrinter

- java.lang.Object
- - de.esprit.common.log.AbstractLogPrinter

- All Implemented Interfaces:
    LogLevelEvent.Source, LogPrinter, java.io.Closeable, java.lang.AutoCloseable
  Direct Known Subclasses:
    LogPrinterConsole, LogPrinterFile, LogPrinterFrame

      public abstract class AbstractLogPrinter
      extends java.lang.Object
      implements LogPrinter

  This class is a default implementation of a `LogPrinter`. On instantiation it registers itself at the underlying `LogChannel` as a `LogMessageEvent.Listener` in order to receive log messages. As long as the `LogLevel` is not set (null) the level from the parent `LogChannel` is used.

  Note that the only method that must be implemented by subclasses is `LogPrinter.getOutput(LogLevel)`, which defines where the output is written to.

  Author:
    Rainer Buesch
  See Also:
    `LogPrinter`, `LogChannel`, `LogMessageEvent`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractLogPrinter(LogChannel logCh)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addLogLevelListener(LogLevelEvent.Listener l)`
    `void` | `close()` Closes this `LogPrinter` and deregisters it from the underlying `LogChannel`.
    `LogChannel` | `getLogChannel()` Returns the underlying `LogChannel` from where the messages are received.
    `LogFormatter` | `getLogFormatter()` Returns the formatter for formatting the logMessage
    `LogLevel` | `getLogLevel()` Returns the current `LogLevel` of this `LogPrinter`.
    `LogMessageEvent.Listener` | `getLogMessageListener()` Needed for the rare cases where this `LogPrinter` needs to be registered at multiple `LogChannel`s.
    `boolean` | `isClosed()`
    `boolean` | `isSilent()` Tells whether this `LogPrinter` is in silent mode.
    `protected void` | `processLogMessage(TextPrintable output, LogFormatter formatter, LogMessageEvent e)` Gives subclasses a chance to hook in before printing the logMessage
    `void` | `removeLogLevelListener(LogLevelEvent.Listener l)`
    `void` | `setLogFormatter(LogFormatter formatter)`
    `void` | `setLogLevel(LogLevel level)` Sets the `LogLevel` individually on this `LogPrinter`.
    `void` | `setSilent(boolean state)` Sets this `LogPrinter` into silent mode.
    `java.lang.String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface de.esprit.common.log.logpr.LogPrinter

      `getOutput, getTypeString`

- - ### Constructor Detail

    - #### AbstractLogPrinter

          public AbstractLogPrinter(LogChannel logCh)

  - ### Method Detail

    - #### setLogFormatter

          public final void setLogFormatter(LogFormatter formatter)

    - #### isClosed

          public boolean isClosed()

    - #### getLogMessageListener

          public final LogMessageEvent.Listener getLogMessageListener()

      Needed for the rare cases where this `LogPrinter` needs to be registered at multiple `LogChannel`s.

    - #### getLogChannel

          public final LogChannel getLogChannel()

      Description copied from interface: `LogPrinter`
      Returns the underlying `LogChannel` from where the messages are received.
      Specified by:
        `getLogChannel` in interface `LogPrinter`

    - #### setLogLevel

          public void setLogLevel(LogLevel level)

      Sets the `LogLevel` individually on this `LogPrinter`. If the level is null then the level of the parent `LogChannel` is used.
      Specified by:
        `setLogLevel` in interface `LogPrinter`

    - #### getLogLevel

          public final LogLevel getLogLevel()

      Returns the current `LogLevel` of this `LogPrinter`. If the printers level is null, then the level of the parent `LogChannel` is returned.
      Specified by:
        `getLogLevel` in interface `LogPrinter`

    - #### getLogFormatter

          public final LogFormatter getLogFormatter()

      Description copied from interface: `LogPrinter`
      Returns the formatter for formatting the logMessage
      Specified by:
        `getLogFormatter` in interface `LogPrinter`

    - #### setSilent

          public void setSilent(boolean state)

      Description copied from interface: `LogPrinter`
      Sets this `LogPrinter` into silent mode. No further output will occur. Note that this does not affect the current `LogLevel`. After re-enabling reporting will continue in current `LogLevel`.
      Specified by:
        `setSilent` in interface `LogPrinter`

    - #### isSilent

          public final boolean isSilent()

      Description copied from interface: `LogPrinter`
      Tells whether this `LogPrinter` is in silent mode.
      Specified by:
        `isSilent` in interface `LogPrinter`

    - #### processLogMessage

          protected void processLogMessage(TextPrintable output,
                               LogFormatter formatter,
                               LogMessageEvent e)

      Gives subclasses a chance to hook in before printing the logMessage

    - #### close

          public void close()

      Closes this `LogPrinter` and deregisters it from the underlying `LogChannel`.
      Specified by:
        `close` in interface `LogPrinter`
      Specified by:
        `close` in interface `java.io.Closeable`
      Specified by:
        `close` in interface `java.lang.AutoCloseable`

    - #### addLogLevelListener

          public final void addLogLevelListener(LogLevelEvent.Listener l)

      Specified by:
        `addLogLevelListener` in interface `LogLevelEvent.Source`

    - #### removeLogLevelListener

          public final void removeLogLevelListener(LogLevelEvent.Listener l)

      Specified by:
        `removeLogLevelListener` in interface `LogLevelEvent.Source`

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

Copyright © 2014 EsprIT-Systems. All Rights Reserved.