Module hw06

Interface ILogEntryProcessor

All Known Subinterfaces:
IStringLogEntryProcessor
All Known Implementing Classes:
AStringLogEntryProcessor, LoggerPanel
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface ILogEntryProcessor
Represents an object that processes a log entry. This could include any of a number of processes, including but not limited to printing, GUI display, storage, transmission, etc.
Author:
swong
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    accept​(ILogEntry logEntry)
    Process the given log entry
    Instantiate a log entry processor that prints to the console using the ILogEntryFormatter.DEFAULT formatter.
    Instantiate a log entry processor that prints to the console using the given log entry formatter.
    Wrap​(BiConsumer<LogLevel,​String> logConsumer, boolean appendLocation)
    Convenience factory to wrap a Consumer<LogEntry, String> in an ILogEntryProcessor so that it can be used in an ILogger.
  • Method Details

    • accept

      void accept(ILogEntry logEntry)
      Process the given log entry
      Parameters:
      logEntry - The log entry to process
    • MakeDefault

      static ILogEntryProcessor MakeDefault()
      Instantiate a log entry processor that prints to the console using the ILogEntryFormatter.DEFAULT formatter. Convenience method that simply delegates to Make(ILogEntryFormatter.DEFAULT).
      Returns:
      A new ILogEntryProcessor instance
    • MakeDefault

      static ILogEntryProcessor MakeDefault(ILogEntryFormatter leFormatter)
      Instantiate a log entry processor that prints to the console using the given log entry formatter. LogLevel.ERROR entries are printed to stderr while others are printed to stdout.
      Parameters:
      leFormatter - The ILogEntryFormatter to use
      Returns:
      A new ILogEntryProcessor instance
    • Wrap

      static ILogEntryProcessor Wrap(BiConsumer<LogLevel,​String> logConsumer, boolean appendLocation)
      Convenience factory to wrap a Consumer<LogEntry, String> in an ILogEntryProcessor so that it can be used in an ILogger. Note that if the Consumer is delegating to a logger, that logger will NOT display the code location of the Consumer call, rather it will display the code location of the logger's log() call. The appendLocation parameter enables the location of ILogEntryProcessor's ILogEntry parameter to be appended to the log message so that it will appear in Consumer's resultant output.
      Parameters:
      logConsumer - The Consumer to wrap
      appendLocation - If true, "[@ code_location]" will be appended to the message.
      Returns:
      An ILogEntryProcessor instance