zz::log::Logger Class Reference

The Logger class Logger is the object to be called to log some message. Each logger may links to several Sinks as logging destinations. More...

#include <zupply.hpp>

Inheritance diagram for zz::log::Logger:
zz::UnMovable

Public Member Functions

 Logger (std::string name)
 Logger default constructor. More...
 
 Logger (std::string name, int levelMask)
 Logger constructor with name and mask. More...
 
template<typename... Args>
detail::LineLogger trace (const char *fmt, const Args &...args)
 Variadic argument style to log some message. Logger.trace(format string, arg1, arg2, arg3, ...) call style.
 
template<typename... Args>
detail::LineLogger debug (const char *fmt, const Args &...args)
 Variadic argument style to log some message. Logger.debug(format string, arg1, arg2, arg3, ...) call style.
 
template<typename... Args>
detail::LineLogger info (const char *fmt, const Args &...args)
 Variadic argument style to log some message. Logger.info(format string, arg1, arg2, arg3, ...) call style.
 
template<typename... Args>
detail::LineLogger warn (const char *fmt, const Args &...args)
 Variadic argument style to log some message. Logger.warn(format string, arg1, arg2, arg3, ...) call style.
 
template<typename... Args>
detail::LineLogger error (const char *fmt, const Args &...args)
 Variadic argument style to log some message. Logger.error(format string, arg1, arg2, arg3, ...) call style.
 
template<typename... Args>
detail::LineLogger fatal (const char *fmt, const Args &...args)
 Variadic argument style to log some message. Logger.fatal(format string, arg1, arg2, arg3, ...) call style.
 
template<typename T >
detail::LineLogger trace (const T &msg)
 Log message and overload with more stream style message. Logger.trace(msg) << ".." call style.
 
template<typename T >
detail::LineLogger debug (const T &msg)
 Log message and overload with more stream style message. Logger.debug(msg) << ".." call style.
 
template<typename T >
detail::LineLogger info (const T &msg)
 Log message and overload with more stream style message. Logger.info(msg) << ".." call style.
 
template<typename T >
detail::LineLogger warn (const T &msg)
 Log message and overload with more stream style message. Logger.warn(msg) << ".." call style.
 
template<typename T >
detail::LineLogger error (const T &msg)
 Log message and overload with more stream style message. Logger.error(msg) << ".." call style.
 
template<typename T >
detail::LineLogger fatal (const T &msg)
 Log message and overload with more stream style message. Logger.fatal(msg) << ".." call style.
 
detail::LineLogger trace ()
 Trace level overloaded with stream style message. More...
 
detail::LineLogger debug ()
 Debug level overloaded with stream style message. More...
 
detail::LineLogger info ()
 Info level overloaded with stream style message. More...
 
detail::LineLogger warn ()
 Warn level overloaded with stream style message. More...
 
detail::LineLogger error ()
 Error level overloaded with stream style message. More...
 
detail::LineLogger fatal ()
 Fatal level overloaded with stream style message. More...
 
void set_level_mask (int levelMask)
 Set level mask to this logger. More...
 
bool should_log (LogLevels msgLevel) const
 Check if a specific level should be logged in this logger. More...
 
std::string name () const
 Get name of the logger. More...
 
std::string to_string ()
 Get user friendly information about this logger. Get informations such as log levels, sink list, etc... More...
 
SinkPtr get_sink (std::string name)
 Get pointer to a sink by name. More...
 
void attach_sink (SinkPtr sink)
 Attach a sink to this logger. More...
 
void detach_sink (SinkPtr sink)
 Detach a sink from this logger. More...
 
void detach_all_sinks ()
 Detach all sinks from this logger.
 
void attach_sink_list (std::vector< std::string > &sinkList)
 Attach the entire vector of sinks to the logger. More...
 
void attach_console ()
 Attach stdout and stderr to the logger. Special case of attach_sink()
 
void detach_console ()
 Detach stdout and stderr from the logger if exist. Special case of detach_sink()
 

Detailed Description

The Logger class Logger is the object to be called to log some message. Each logger may links to several Sinks as logging destinations.

Constructor & Destructor Documentation

zz::log::Logger::Logger ( std::string  name)
inline

Logger default constructor.

Parameters
nameLogger's name, need a name to retrieve the logger
zz::log::Logger::Logger ( std::string  name,
int  levelMask 
)
inline

Logger constructor with name and mask.

Parameters
name
levelMaskSpecify which levels should be logged

Member Function Documentation

void zz::log::Logger::attach_sink ( SinkPtr  sink)

Attach a sink to this logger.

Parameters
sink
void zz::log::Logger::attach_sink_list ( std::vector< std::string > &  sinkList)

Attach the entire vector of sinks to the logger.

Parameters
sinkList
detail::LineLogger zz::log::Logger::debug ( )

Debug level overloaded with stream style message.

Returns
LineLogger
void zz::log::Logger::detach_sink ( SinkPtr  sink)

Detach a sink from this logger.

Parameters
sink
detail::LineLogger zz::log::Logger::error ( )

Error level overloaded with stream style message.

Returns
LineLogger
detail::LineLogger zz::log::Logger::fatal ( )

Fatal level overloaded with stream style message.

Returns
LineLogger
SinkPtr zz::log::Logger::get_sink ( std::string  name)

Get pointer to a sink by name.

Parameters
nameName of the sink
Returns
Shared pointer to the sink, return nullptr if not found.
detail::LineLogger zz::log::Logger::info ( )

Info level overloaded with stream style message.

Returns
LineLogger
std::string zz::log::Logger::name ( ) const
inline

Get name of the logger.

Returns
Name of the logger
void zz::log::Logger::set_level_mask ( int  levelMask)
inline

Set level mask to this logger.

Parameters
levelMask
bool zz::log::Logger::should_log ( LogLevels  msgLevel) const
inline

Check if a specific level should be logged in this logger.

Parameters
msgLevel
Returns
True if the level should be logged
std::string zz::log::Logger::to_string ( )

Get user friendly information about this logger. Get informations such as log levels, sink list, etc...

Returns
User friendly string info.
detail::LineLogger zz::log::Logger::trace ( )

Trace level overloaded with stream style message.

Returns
LineLogger
detail::LineLogger zz::log::Logger::warn ( )

Warn level overloaded with stream style message.

Returns
LineLogger

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