Class LoggingSystemTurboFilter

java.lang.Object
ch.qos.logback.core.spi.ContextAwareBase
ch.qos.logback.classic.turbo.TurboFilter
com.inductiveautomation.ignition.common.logging.LoggingSystemTurboFilter
All Implemented Interfaces:
ch.qos.logback.core.spi.ContextAware, ch.qos.logback.core.spi.LifeCycle

public class LoggingSystemTurboFilter extends ch.qos.logback.classic.turbo.TurboFilter
This is our main filter in the logging system. A LogBack TurboFilter is one that is consulted before a log event is generated, for every logging event in the system (so it must be fast!). It has the ability to deny an event before it's generated, or bypass the rest of the filters and automatically accept it.

Our implementation here is focused on the functionality we add around MDC values. It has the ability to filter based on mdc values, or to emulate logger levels, but for MDC key/values instead of logger names.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    protected static class 
    We can do 2 things: 1) set levels for specific property values (which bypass/ignore logger levels) 2) set property filters, so that events only pass when the property matches.
  • Field Summary

    Fields inherited from class ch.qos.logback.core.spi.ContextAwareBase

    context
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addFilter(String key, String value)
     
    void
     
    void
     
    ch.qos.logback.core.spi.FilterReply
    decide(Map<String,String> mdcMap, ch.qos.logback.classic.Level level, boolean strict)
    This gets called 2 times- one as an actual turbofilter, in which case strict=false, and we only care about promoting events.
    ch.qos.logback.core.spi.FilterReply
    decide(org.slf4j.Marker marker, ch.qos.logback.classic.Logger logger, ch.qos.logback.classic.Level level, String format, Object[] params, Throwable t)
     
     
    Returns the full set of key filters currently applied, in a map with Key Name -> Value Name -> Level hierarchy
    void
    removeFilter(String key, String value)
     
    void
    setLevel(String key, String value, ch.qos.logback.classic.Level level)
     
    boolean
    wasAcceptedBy(ch.qos.logback.classic.spi.ILoggingEvent event)
     

    Methods inherited from class ch.qos.logback.classic.turbo.TurboFilter

    getName, isStarted, setName, start, stop

    Methods inherited from class ch.qos.logback.core.spi.ContextAwareBase

    addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContext

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • LoggingSystemTurboFilter

      public LoggingSystemTurboFilter()
  • Method Details

    • keyFilterValues

      public Map<String,Map<String,Level>> keyFilterValues()
      Returns the full set of key filters currently applied, in a map with Key Name -> Value Name -> Level hierarchy
      Returns:
      map of currently active filters, its values, and the Levelof the value
    • clear

      public void clear()
    • getOrCreate

      protected LoggingSystemTurboFilter.MDCKeyFilter getOrCreate(String key)
    • setLevel

      public void setLevel(String key, String value, ch.qos.logback.classic.Level level)
    • clearLevels

      public void clearLevels()
    • addFilter

      public void addFilter(String key, String value)
    • removeFilter

      public void removeFilter(String key, String value)
    • decide

      public ch.qos.logback.core.spi.FilterReply decide(org.slf4j.Marker marker, ch.qos.logback.classic.Logger logger, ch.qos.logback.classic.Level level, String format, Object[] params, Throwable t)
      Specified by:
      decide in class ch.qos.logback.classic.turbo.TurboFilter
    • wasAcceptedBy

      public boolean wasAcceptedBy(ch.qos.logback.classic.spi.ILoggingEvent event)
    • decide

      public ch.qos.logback.core.spi.FilterReply decide(Map<String,String> mdcMap, ch.qos.logback.classic.Level level, boolean strict)
      This gets called 2 times- one as an actual turbofilter, in which case strict=false, and we only care about promoting events. Then, when strict is true, we're trying to decide what appender hte message should go on. In that case, we must match exactly.