Module hw06

Interface ILogEntryFormatter

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 ILogEntryFormatter
A functional which will convert an ILogEntry into a String representation.
Author:
swong
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    A default log entry formatter that uses the default string format.
    static String
    The string format used by the DEFAULT formatter used to convert a log entry into a single String.
  • Method Summary

    Modifier and Type
    Method
    Description
    apply​(ILogEntry logEntry)
    Format the given log entry as a String
    MakeFormatter​(String formatStr)
    A default log entry formatter that uses the given string format.
  • Field Details

    • DEFAULT_FORMAT

      static final String DEFAULT_FORMAT
      The string format used by the DEFAULT formatter used to convert a log entry into a single String. The format string parameters are in this order: (level, msg, loc) Using indexed positional arguments ("%X$") enables the parameters to be used in any order as well as to use only some of the parameters.
      See Also:
      Constant Field Values
    • DEFAULT

      static final ILogEntryFormatter DEFAULT
      A default log entry formatter that uses the default string format.
  • Method Details

    • apply

      String apply(ILogEntry logEntry)
      Format the given log entry as a String
      Parameters:
      logEntry - The log entry to format
      Returns:
      A String representation of the given log entry
    • MakeFormatter

      static ILogEntryFormatter MakeFormatter(String formatStr)
      A default log entry formatter that uses the given string format. See the DEFAULT_FORMAT for an example. Use of argument positional indices ("%x$") in the format string will enable the log entry values to be placed anywhere desired in the output string, including ignoring a value if desired.
      Parameters:
      formatStr - A format string that takes 3 values in the order: (LogLevel, log_msg_str, code_loc_str) though not all 3 need to be used.
      Returns:
      An ILogEntryFormatter instance