Module hw06

Interface ILogger

All Known Implementing Classes:
Logger

public interface ILogger
Represents a logger object that is the head node of a chain of logger objects.
Author:
swong
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static ILogger
    Null logger instance that is a no-op or return false except for its append() method which returns the given ILogger object.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Add the given log entry processor to the set of processors being used.
    append​(ILogger logger)
    Appends the chain represented by the given logger into this logger chain.
    boolean
    find​(ILogger logger)
    TYPICAL DEVELOPER CODE NEVER CALLS THIS METHOD! Searches the this logger chain to find any occurrence of the given ILogger.
    void
    log​(ILogEntry logEntry)
    TYPICAL DEVELOPER CODE NEVER CALLS THIS METHOD! Log the given log entry using a completed ILogEntry object where the code location is being explicitly specified.
    void
    log​(LogLevel level, String msg)
    Log the given log entry where the code location is being automatically calculate.
    remove​(ILogger logger)
    Remove the given logger from anywhere in the logger chain that begins with this logger.
    boolean
    Remove the given log entry processor from the set of processors being used.
    void
    setLogLevel​(LogLevel logLevel)
    Sets the minimum log level to be displayed.
    void
    Set the log entry processor being used.
  • Field Details

    • NULL

      static final ILogger NULL
      Null logger instance that is a no-op or return false except for its append() method which returns the given ILogger object.
  • Method Details

    • log

      void log(LogLevel level, String msg)
      Log the given log entry where the code location is being automatically calculate.
      Parameters:
      level - The log level of the entry
      msg - The message of the entry
    • log

      void log(ILogEntry logEntry)
      TYPICAL DEVELOPER CODE NEVER CALLS THIS METHOD! Log the given log entry using a completed ILogEntry object where the code location is being explicitly specified. This method is used by ILoggers during a chained log.
      Parameters:
      logEntry - The log entry to process
    • setLogLevel

      void setLogLevel(LogLevel logLevel)
      Sets the minimum log level to be displayed.
      Parameters:
      logLevel - The minimum log level to be displayed.
    • setLogProcessor

      void setLogProcessor(ILogEntryProcessor logProcFn)
      Set the log entry processor being used. This processor will replace ALL processors currently in use.
      Parameters:
      logProcFn - The new log processor function.
    • addLogProcessor

      boolean addLogProcessor(ILogEntryProcessor logProcFn)
      Add the given log entry processor to the set of processors being used. Duplicate processors will not be added and will return a False value.
      Parameters:
      logProcFn - The new log processor function to add.
      Returns:
      true if the processor was successfully added, false if the processor was already in the current set of processors or could not be added.
    • removeLogProcessor

      boolean removeLogProcessor(ILogEntryProcessor logProcFn)
      Remove the given log entry processor from the set of processors being used. The last processor cannot be removed (returns false).
      Parameters:
      logProcFn - The new log processor function to remove.
      Returns:
      true if the processor was found and removed, false otherwise.
    • append

      ILogger append(ILogger logger)
      Appends the chain represented by the given logger into this logger chain.
      Parameters:
      logger - The logger and the rest of its chain to append to the end of this logger's chain.
      Returns:
      The logger at the head of the new chain. A non-empty chain returns itself while an empty chain returns the given logger.
      Throws:
      IllegalStateException - if a circular chain would be created.
    • remove

      ILogger remove(ILogger logger)
      Remove the given logger from anywhere in the logger chain that begins with this logger.
      Parameters:
      logger - The logger to remove from the chain.
      Returns:
      Returns the head of the new logger chain, typically this ILogger unless this logger is the one being removed, when ILogger.NULL is returned.
    • find

      boolean find(ILogger logger)
      TYPICAL DEVELOPER CODE NEVER CALLS THIS METHOD! Searches the this logger chain to find any occurrence of the given ILogger. This method is used between ILoggers to check for potential loops in chains.
      Parameters:
      logger - The logger chain to search for
      Returns:
      true if found, false otherwise