DCCL v4
dccl::Logger Class Reference

The DCCL Logger class. Do not instantiate this class directly. Rather, use the dccl::dlog object. More...

#include <dccl/logger.h>

Inheritance diagram for dccl::Logger:

Public Member Functions

bool check (logger::Verbosity verbosity)
 Same as is() but doesn't set the verbosity or lock the mutex.
 
bool is (logger::Verbosity verbosity, logger::Group group=logger::GENERAL)
 Indicates the verbosity of the Logger until the next std::flush or std::endl. The boolean return is used to take advantage of short-circuit evaluation of && to avoid spending CPU time generating log files that if they are not used. This locks the dlog mutex when running with DCCL_THREAD_SUPPORT. More...
 
template<typename Slot >
void connect (int verbosity_mask, Slot slot)
 Connect the output of one or more given verbosities to a slot (function pointer or similar) More...
 
template<typename Obj >
void connect (int verbosity_mask, Obj *obj, void(Obj::*mem_func)(const std::string &msg, logger::Verbosity vrb, logger::Group grp))
 Connect the output of one or more given verbosities to a member function. More...
 
void connect (int verbosity_mask, std::ostream *os, bool add_timestamp=true)
 Connect the output of one or more given verbosities to a std::ostream. More...
 
void disconnect (int verbosity_mask)
 Disconnect all slots for one or more given verbosities.
 

Detailed Description

The DCCL Logger class. Do not instantiate this class directly. Rather, use the dccl::dlog object.

Definition at line 174 of file logger.h.

Member Function Documentation

◆ connect() [1/3]

template<typename Obj >
void dccl::Logger::connect ( int  verbosity_mask,
Obj *  obj,
void(Obj::*)(const std::string &msg, logger::Verbosity vrb, logger::Group grp)  mem_func 
)
inline

Connect the output of one or more given verbosities to a member function.

Parameters
verbosity_maskA bitmask representing the verbosity or verbosities to send to this slot. For example, you can use connect(WARN | INFO, this, &MyClass::slot) to send both WARN and INFO messages to MyClass::slot.
objPointer to the instantiation of the class of which this member function should be called.
mem_funcMember function of type (void*) (const std::string& msg, logger::Verbosity vrb, logger::Group grp)

Definition at line 227 of file logger.h.

◆ connect() [2/3]

template<typename Slot >
void dccl::Logger::connect ( int  verbosity_mask,
Slot  slot 
)
inline

Connect the output of one or more given verbosities to a slot (function pointer or similar)

Parameters
verbosity_maskA bitmask representing the verbosity or verbosities to send to this slot. For example, you can use connect(WARN | INFO, slot) to send both WARN and INFO messages to slot.
slotThe slot must be a function pointer or like object (e.g. std::function) of type (void*) (const std::string& msg, logger::Verbosity vrb, logger::Group grp)

Definition at line 214 of file logger.h.

◆ connect() [3/3]

void dccl::Logger::connect ( int  verbosity_mask,
std::ostream *  os,
bool  add_timestamp = true 
)
inline

Connect the output of one or more given verbosities to a std::ostream.

Parameters
verbosity_maskA bitmask representing the verbosity or verbosities to send to this slot. For example, you can use connect(WARN | INFO, &std::cout) to send both WARN and INFO messages to std::cout.
osPointer to a std::ostream
add_timestampIf true, prepend the current timestamp of the message to each log message.

Definition at line 241 of file logger.h.

◆ is()

bool dccl::Logger::is ( logger::Verbosity  verbosity,
logger::Group  group = logger::GENERAL 
)
inline

Indicates the verbosity of the Logger until the next std::flush or std::endl. The boolean return is used to take advantage of short-circuit evaluation of && to avoid spending CPU time generating log files that if they are not used. This locks the dlog mutex when running with DCCL_THREAD_SUPPORT.

The typical usage is

dlog.is(INFO) && dlog << "Something of interest." << std::endl;
dlog.is(WARN, ENCODE) && dlog << "Something bad happened while encoding." << std::endl;
Parameters
verbosityThe verbosity level to tag the following message with. These levels are used to direct the output of dlog to different logs or omit them completely.
groupThe group that this message belongs to.

Definition at line 192 of file logger.h.


The documentation for this class was generated from the following file:
dccl::Logger::is
bool is(logger::Verbosity verbosity, logger::Group group=logger::GENERAL)
Indicates the verbosity of the Logger until the next std::flush or std::endl. The boolean return is u...
Definition: logger.h:192