LogFilter Class Reference

Simple filter which decides whether the message should be filtered basing on its LogLevel and origin. More...

#include <LogFilter.h>

List of all members.

Public Member Functions

 LogFilter (const RegistryKey &key)
 Constructor. Configures the LogFilter according to the information stored in the provided registry key.
 LogFilter (LogLevel defaultLogLevel)
 Constructor. Creates a LogFilter with no OriginRules.
bool IsFiltered (const LogInfo &logInfo)
 Helper method which uses GetMaximumLogLevel() to determine whether message with provided LogInfo should be filtered.
LogLevel GetMaximumLogLevel (const std::tstring &scopeLoggerName)
 This method returns the maximum LogLevel at which messages should be passed through this filter if they originate from "origin".

Private Types

typedef std::map< std::tstring,
LogLevel >::const_iterator 
OriginRulesIterator

Private Member Functions

void StripLastPart (std::tstring &originPrefix)
 Helper method which does in-place removal of the last part of the origin string (to and including the last dot character).

Private Attributes

std::map< std::tstring, LogLevel > OriginRules
 Map containing the filtering rules.
LogLevel DefaultLogLevel
 Default LogLevel to use when there is no match in OriginRules for particular origin.


Detailed Description

Simple filter which decides whether the message should be filtered basing on its LogLevel and origin.

What this documentation and the LogFilter implementation refer to as "origin" is equivalent to the name of the ScopeLogger from which the log message originated.

Definition at line 39 of file LogFilter.h.


Constructor & Destructor Documentation

LogFilter ( const RegistryKey &  key  )  [inline]

Constructor. Configures the LogFilter according to the information stored in the provided registry key.

The structure of the configuration in the registry mirrors the structure of LogFilter object:

  • DefaultLogLevel is stored in a value called "DefaultLogLevel",
  • OriginRules are stored as DWORD values in OriginRules subkey.

Definition at line 101 of file LogFilter.h.

References LogFilter::DefaultLogLevel, and LogFilter::OriginRules.

LogFilter ( LogLevel  defaultLogLevel  )  [inline]

Constructor. Creates a LogFilter with no OriginRules.

Parameters:
defaultLogLevel The default LogLevel.

Definition at line 99 of file LogFilter.h.


Member Function Documentation

LogLevel GetMaximumLogLevel ( const std::tstring &  scopeLoggerName  )  [inline]

This method returns the maximum LogLevel at which messages should be passed through this filter if they originate from "origin".

Implementation of this method follows this algorithm:

  • originPrefix := logInfo.ScopeLoggerName
  • while originPrefix is not empty
    • check if there is a mapping from originPrefix in OriginRules
    • if yes then
      • add (origin -> OriginRules[originPrefix]) mapping to OriginRules
        • this point is not mandatory, but it reduces the complexity of the algorithm, because for each ScopeLoggerName we need to go through all hierarchy levels only once.
      • return OriginRules[originPrefix]
    • strip last part of the originPrefix (to and including the last dot)
  • return DefaultLogLevel

Definition at line 136 of file LogFilter.h.

References LogFilter::DefaultLogLevel, LogFilter::OriginRules, and LogFilter::StripLastPart().

Referenced by Logger::GetMaximumLogLevel(), and LogFilter::IsFiltered().


Member Data Documentation

std::map<std::tstring, LogLevel> OriginRules [private]

Map containing the filtering rules.

Each mapping in the form ("someOrigin" -> someLevel) means that all messages whose:

  • origin matches "someOrigin.*", and
  • "someOrigin" is the longest match from all mappings in OriginRules, and
  • logLevel is above someLevel

should be filtered out.

Definition at line 52 of file LogFilter.h.

Referenced by LogFilter::GetMaximumLogLevel(), and LogFilter::LogFilter().


The documentation for this class was generated from the following file:

Generated on Thu Sep 17 15:05:17 2009 for Logging by  doxygen 1.5.8