de.esprit.common.log

## Class LogFormatter

- java.lang.Object
- - de.esprit.common.util.DumpableObject
  - - de.esprit.common.log.LogFormatter

- All Implemented Interfaces:
    Dumpable
  Direct Known Subclasses:
    DefaultLogFormatter, NdfLogFormatter

      public abstract class LogFormatter
      extends DumpableObject

  This class formats the given `LogMessageEvent` according to the settings of the formatting flags. The supported formatting flags are:
  - Timestamp
    Prints the exact timestamp when the message occurred
  - LogLevel
    Prints the log-level
  - Thread info
    Prints the name of the thread who reported the message
  - Class info
    Prints the name of the object/class that reported the message
  - Stacktrace
    Prints the full stack log of any exception received
  Author:
    Rainer Buesch

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `LogFormatter()`
    `LogFormatter(boolean isLogTs, boolean isLogger, boolean isLevel, boolean isClass, boolean isStackTr, boolean isThread)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.String` | `formatMessage(LogMessageEvent e)`
    `protected abstract java.lang.String` | `formatMessage(java.lang.Object caller, LogLevel level, java.lang.String loggerName, java.lang.String message, java.lang.String logTs, java.lang.String thread, java.lang.Throwable error)`
    `boolean` | `isPrintClass()`
    `boolean` | `isPrintLogger()`
    `boolean` | `isPrintLogLevel()`
    `boolean` | `isPrintStackTrace()`
    `boolean` | `isPrintThread()`
    `boolean` | `isPrintTimestamp()`
    `void` | `setPrintClass(boolean isClass)`
    `void` | `setPrintLogger(boolean isLogger)`
    `void` | `setPrintLogLevel(boolean isLevel)`
    `void` | `setPrintStackTrace(boolean isStackTr)`
    `void` | `setPrintThread(boolean isThread)`
    `void` | `setPrintTimestamp(boolean isLogTs)`
    `DumpString` | `toDumpString(DumpString s)` This method allows subclasses to add values to the existing DumpString of the superclass.
    `ToString` | `toString(ToString s)` This method allows subclasses to add values to the existing ToString of the superclass.

    - ### Methods inherited from class de.esprit.common.util.DumpableObject

      `configureDumpHeadlineLength, configureDumpMaxElementsPrinted, copyDumpStringValues, copyToStringValues, createDumpHeader, toDumpString, toString`

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

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

- - ### Constructor Detail

    - #### LogFormatter

          public LogFormatter()

    - #### LogFormatter

          public LogFormatter(boolean isLogTs,
                      boolean isLogger,
                      boolean isLevel,
                      boolean isClass,
                      boolean isStackTr,
                      boolean isThread)

  - ### Method Detail

    - #### setPrintLogger

          public final void setPrintLogger(boolean isLogger)

    - #### setPrintClass

          public final void setPrintClass(boolean isClass)

    - #### setPrintTimestamp

          public final void setPrintTimestamp(boolean isLogTs)

    - #### setPrintStackTrace

          public final void setPrintStackTrace(boolean isStackTr)

    - #### setPrintLogLevel

          public final void setPrintLogLevel(boolean isLevel)

    - #### setPrintThread

          public final void setPrintThread(boolean isThread)

    - #### isPrintClass

          public final boolean isPrintClass()

    - #### isPrintTimestamp

          public final boolean isPrintTimestamp()

    - #### isPrintLogger

          public final boolean isPrintLogger()

    - #### isPrintLogLevel

          public final boolean isPrintLogLevel()

    - #### isPrintStackTrace

          public final boolean isPrintStackTrace()

    - #### isPrintThread

          public final boolean isPrintThread()

    - #### formatMessage

          public final java.lang.String formatMessage(LogMessageEvent e)

    - #### formatMessage

          protected abstract java.lang.String formatMessage(java.lang.Object caller,
                                       LogLevel level,
                                       java.lang.String loggerName,
                                       java.lang.String message,
                                       java.lang.String logTs,
                                       java.lang.String thread,
                                       java.lang.Throwable error)

    - #### toString

          public ToString toString(ToString s)

      Description copied from interface: `Dumpable`
      This method allows subclasses to add values to the existing ToString of the superclass. Usually subclasses only need to override this method.
      Specified by:
        `toString` in interface `Dumpable`
      Overrides:
        `toString` in class `DumpableObject`

    - #### toDumpString

          public DumpString toDumpString(DumpString s)

      Description copied from interface: `Dumpable`
      This method allows subclasses to add values to the existing DumpString of the superclass. Usually subclasses only need to override this method.
      Specified by:
        `toDumpString` in interface `Dumpable`
      Overrides:
        `toDumpString` in class `DumpableObject`

Copyright © 2014 EsprIT-Systems. All Rights Reserved.