irccd  3.0.3
Public Member Functions | Protected Member Functions | Friends | List of all members
irccd::daemon::logger::sink Class Referenceabstract

Interface to implement new logger mechanisms. More...

#include <logger.hpp>

Inheritance diagram for irccd::daemon::logger::sink:
irccd::daemon::logger::console_sink irccd::daemon::logger::file_sink irccd::daemon::logger::silent_sink

Public Member Functions

 sink ()
 
virtual ~sink ()=default
 
auto is_verbose () const noexcept -> bool
 
void set_verbose (bool mode) noexcept
 
void set_filter (filter &filter) noexcept
 
auto info (std::string_view category, std::string_view component) -> logger
 
template<typename Loggable >
auto info (const Loggable &loggable) -> logger
 
auto warning (std::string_view category, std::string_view component) -> logger
 
template<typename Loggable >
auto warning (const Loggable &loggable) -> logger
 
auto debug (std::string_view category, std::string_view component) -> logger
 
template<typename Loggable >
auto debug (const Loggable &loggable) -> logger
 

Protected Member Functions

virtual void write_debug (const std::string &line)=0
 
virtual void write_info (const std::string &line)=0
 
virtual void write_warning (const std::string &line)=0
 

Friends

class logger
 Make logger friend. More...
 

Detailed Description

Interface to implement new logger mechanisms.

Derive from this class and implement write_info, write_warning and write_debug functions.

See also
file_sink
console_sink
syslog_sink
silent_sink

Constructor & Destructor Documentation

◆ sink()

irccd::daemon::logger::sink::sink ( )

Default constructor.

◆ ~sink()

virtual irccd::daemon::logger::sink::~sink ( )
virtualdefault

Virtual destructor defaulted.

Member Function Documentation

◆ debug() [1/2]

template<typename Loggable >
auto irccd::daemon::logger::sink::debug ( const Loggable &  loggable) -> logger
inline

Convenient function with loggable objects.

Parameters
loggablethe loggable object
Returns
the output stream
See also
type_traits

◆ debug() [2/2]

auto irccd::daemon::logger::sink::debug ( std::string_view  category,
std::string_view  component 
) -> logger

Get the stream for debug messages.

If message is specified, a new line character is appended.

Parameters
categorythe category subsystem
componentthe optional component
Returns
the output stream
Note
Has no effect if compiled in release mode.

◆ info() [1/2]

template<typename Loggable >
auto irccd::daemon::logger::sink::info ( const Loggable &  loggable) -> logger
inline

Convenient function with loggable objects.

Parameters
loggablethe loggable object
Returns
the output stream
See also
type_traits

◆ info() [2/2]

auto irccd::daemon::logger::sink::info ( std::string_view  category,
std::string_view  component 
) -> logger

Get the stream for informational messages.

If message is specified, a new line character is appended.

Parameters
categorythe category subsystem
componentthe optional component
Returns
the output stream
Note
Has no effect if verbose is set to false.

◆ is_verbose()

auto irccd::daemon::logger::sink::is_verbose ( ) const -> bool
noexcept

Tells if logger is verbose.

Returns
true if verbose

◆ set_filter()

void irccd::daemon::logger::sink::set_filter ( filter filter)
noexcept

Set an optional filter.

Parameters
filterthe filter

◆ set_verbose()

void irccd::daemon::logger::sink::set_verbose ( bool  mode)
noexcept

Set the verbosity mode.

Parameters
modethe new mode

◆ warning() [1/2]

template<typename Loggable >
auto irccd::daemon::logger::sink::warning ( const Loggable &  loggable) -> logger
inline

Convenient function with loggable objects.

Parameters
loggablethe loggable object
Returns
the output stream
See also
type_traits

◆ warning() [2/2]

auto irccd::daemon::logger::sink::warning ( std::string_view  category,
std::string_view  component 
) -> logger

Get the stream for warnings.

If message is specified, a new line character is appended.

Parameters
categorythe category subsystem
componentthe optional component
Returns
the output stream

◆ write_debug()

virtual void irccd::daemon::logger::sink::write_debug ( const std::string &  line)
protectedpure virtual

Write a debug message.

This function is called only if NDEBUG is not defined.

Parameters
linethe data
See also
log::debug

Implemented in irccd::daemon::logger::silent_sink, irccd::daemon::logger::file_sink, and irccd::daemon::logger::console_sink.

◆ write_info()

virtual void irccd::daemon::logger::sink::write_info ( const std::string &  line)
protectedpure virtual

Write a information message.

The function is called only if verbose is true.

Parameters
linethe data
See also
log::info

Implemented in irccd::daemon::logger::silent_sink, irccd::daemon::logger::file_sink, and irccd::daemon::logger::console_sink.

◆ write_warning()

virtual void irccd::daemon::logger::sink::write_warning ( const std::string &  line)
protectedpure virtual

Write an error message.

This function is always called.

Parameters
linethe data
See also
log::warning

Implemented in irccd::daemon::logger::silent_sink, irccd::daemon::logger::file_sink, and irccd::daemon::logger::console_sink.

Friends And Related Function Documentation

◆ logger

friend class logger
friend

Make logger friend.


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