olp-cpp-sdk  1.22.0
Public Member Functions | Static Public Member Functions | Friends | List of all members
olp::logging::FilterGroup Class Reference

Groups together log levels for different tags. More...

#include <FilterGroup.h>

Public Member Functions

 FilterGroup (const FilterGroup &)=default
 The default copy constructor.
 
FilterGroupoperator= (const FilterGroup &)=default
 The default copy assignment operator.
 
 FilterGroup (FilterGroup &&other) noexcept
 The default move constructor.
 
FilterGroupoperator= (FilterGroup &&other) noexcept
 The default move assignment operator.
 
boost::optional< Level > getLevel () const
 Gets the default log level. More...
 
FilterGroupsetLevel (Level level)
 Sets the default log level. More...
 
FilterGroupclearLevel ()
 Clears the default log level. More...
 
boost::optional< Level > getLevel (const std::string &tag) const
 Gets the log level for a tag. More...
 
FilterGroupsetLevel (Level level, const std::string &tag)
 Sets the log level for a tag. More...
 
FilterGroupclearLevel (const std::string &tag)
 Clears the log level for a tag. More...
 
FilterGroupclear ()
 Clears the filter group.
 
bool load (const std::string &fileName)
 Loads the filter group from a file. More...
 
bool load (std::istream &stream)
 Loads the filter group from a stream. More...
 

Static Public Member Functions

static boost::optional< Level > stringToLevel (const std::string &levelStr)
 Converts the string log level to the enum level format. More...
 

Friends

class Log
 

Detailed Description

Groups together log levels for different tags.

It helps to apply groups of level filters together.

Member Function Documentation

◆ clearLevel() [1/2]

FilterGroup & olp::logging::FilterGroup::clearLevel ( )
inline

Clears the default log level.

If the default log level is unset, it does not change when the filter group is applied.

◆ clearLevel() [2/2]

FilterGroup & olp::logging::FilterGroup::clearLevel ( const std::string &  tag)
inline

Clears the log level for a tag.

If the log level for a tag is unset, the default log level is used instead.

◆ getLevel() [1/2]

boost::optional< Level > olp::logging::FilterGroup::getLevel ( ) const
inline

Gets the default log level.

Returns
The default log level or boost::none if the level is not set.

◆ getLevel() [2/2]

boost::optional< Level > olp::logging::FilterGroup::getLevel ( const std::string &  tag) const
inline

Gets the log level for a tag.

Parameters
tagThe tag for which to get the log level.
Returns
The log level for the tag, or boost::none if the level is not set.

◆ load() [1/2]

bool olp::logging::FilterGroup::load ( const std::string &  fileName)

Loads the filter group from a file.

Parameters
fileNameThe file from which to load the configuration.
Returns
True if the load was successful; false otherwise. If unsuccessful, this is cleared.

◆ load() [2/2]

bool olp::logging::FilterGroup::load ( std::istream &  stream)

Loads the filter group from a stream.

The stream should contain text data. The format of the stream:

  • Blank lines or lines that start with "#" are ignored.
  • Use the following format for tag log levels: tag: level. For example:
    • mylib: warning
    • theirlib: info
    • otherlib: off
  • Use the following format for the default log level: : level. For example: : error
  • Whitespaces are trimmed.
  • The case is ignored for levels.

The filter groups are cleared before the content of the stream is applied.

Parameters
streamThe stream from which to load the configuration.
Returns
True if the load was successful; false otherwise. If unsuccessful, this is cleared.

◆ setLevel() [1/2]

FilterGroup & olp::logging::FilterGroup::setLevel ( Level  level)
inline

Sets the default log level.

Parameters
levelThe default log level.

◆ setLevel() [2/2]

FilterGroup & olp::logging::FilterGroup::setLevel ( Level  level,
const std::string &  tag 
)
inline

Sets the log level for a tag.

Parameters
levelThe log level for a tag.
tagThe tag for which to set the level.

◆ stringToLevel()

static boost::optional<Level> olp::logging::FilterGroup::stringToLevel ( const std::string &  levelStr)
static

Converts the string log level to the enum level format.

Parameters
levelStrThe string level to convert.
Returns
The converted level.

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