COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
Public Types | Public Member Functions | Private Attributes | List of all members
LogLevelFilter Class Reference

Filters log messages corresponding to their level. More...

#include <LogLevelFilter.hpp>

Public Types

typedef char char_type
 
typedef boost::iostreams::multichar_output_filter_tag category
 

Public Member Functions

 LogLevelFilter (LogLevel level)
 Constructor. More...
 
void set_filter (LogLevel level)
 Sets the default log level. More...
 
LogLevel get_filter () const
 Gives the default log level. More...
 
void set_tmp_log_level (const Uint level)
 
void set_log_level (const Uint level)
 Sets the current log level. More...
 
Uint get_log_level () const
 Gives the current log level. More...
 
void resetToDefaultLevel ()
 Resets the current log level to the default level. More...
 
template<typename Sink >
std::streamsize write (Sink &sink, const char_type *data, std::streamsize size)
 Forwards a message. More...
 

Private Attributes

LogLevel m_filter
 The filtering value for the log level. More...
 
Uint m_log_level
 The default log level. More...
 
Uint m_tmp_log_level
 A temporary override of the log level. More...
 

Detailed Description

Filters log messages corresponding to their level.

This class is written to act as a Boost.Iostreams filter. It defines char_type and category types and a write method for that purpose.
The class is constructed with a filter value. An additional level can be set that gets compared to the filter. If the level is higher or equal to the filter, the message gets forwarded.
A temporary override of the level is possible, using set_tmp_log_level(), which gets restored by calling resetToDefaultLevel()

Example:
If the filter is set to only pass messages of WARNING, and the level is set to:

Author
Quentin Gasper
Willem Deconinck

Definition at line 42 of file LogLevelFilter.hpp.

Member Typedef Documentation

typedef boost::iostreams::multichar_output_filter_tag category

Definition at line 47 of file LogLevelFilter.hpp.

typedef char char_type

Definition at line 46 of file LogLevelFilter.hpp.

Constructor & Destructor Documentation

Constructor.

Parameters
levelDefault log level.

Definition at line 12 of file LogLevelFilter.cpp.

Member Function Documentation

LogLevel get_filter ( ) const

Gives the default log level.

Returns
Returns the default log level.

Definition at line 31 of file LogLevelFilter.cpp.

Uint get_log_level ( ) const

Gives the current log level.

Returns
Returns the current log level.

Definition at line 48 of file LogLevelFilter.cpp.

void resetToDefaultLevel ( )

Resets the current log level to the default level.

Calling this method is equivalent to:

filter.setCurrentLogLevel(filter.getLogLevel());

Definition at line 56 of file LogLevelFilter.cpp.

void set_filter ( LogLevel  level)

Sets the default log level.

Parameters
levelThe new default level.

Definition at line 23 of file LogLevelFilter.cpp.

void set_log_level ( const Uint  level)

Sets the current log level.

Parameters
levelThe current log level.

Definition at line 39 of file LogLevelFilter.cpp.

void set_tmp_log_level ( const Uint  level)

Definition at line 64 of file LogLevelFilter.cpp.

std::streamsize write ( Sink &  sink,
const char_type data,
std::streamsize  size 
)
inline

Forwards a message.

Example:
If the filter is set to only pass messages of WARNING, and the level is set to:

  • DEBUG, then it is blocked
  • INFO, then it is blocked
  • WARNING, then it is forwarded
  • ERROR, then it is forwarded
    Parameters
    sinkThe sink to which the message has to be written.
    dataMessage data.
    sizeMessage data size.
    Returns
    Always returns size.

Definition at line 97 of file LogLevelFilter.hpp.

Member Data Documentation

LogLevel m_filter
private

The filtering value for the log level.

Definition at line 110 of file LogLevelFilter.hpp.

Uint m_log_level
private

The default log level.

Definition at line 113 of file LogLevelFilter.hpp.

Uint m_tmp_log_level
private

A temporary override of the log level.

Definition at line 116 of file LogLevelFilter.hpp.


The documentation for this class was generated from the following files:
Send comments to:
COOLFluiD Web Admin