Simple-Log  alpha-v0.7
sl::log::BaseLogger< TRecord > Class Template Reference

Convenience class for generating Record s. More...

#include <Logger.hpp>

Public Types

using Record_t = std::remove_cvref_t< TRecord >
 
using RecordSetters_t = RecordSetters< Record_t >
 
using SeverityLevel_t = RecordSeverity_t< Record_t >
 
using Channel_t = RecordChannel_t< Record_t >
 
using RecordBuilder_t = RecordBuilder< Record_t >
 
using LogCallback_t = std::function< void(Record_t)>
 

Public Member Functions

 BaseLogger (LogCallback_t logCallback, SeverityLevel_t defaultSeverityLvl={}, Channel_t defaultChannel={}) noexcept
 Constructor. More...
 
 ~BaseLogger () noexcept=default
 Destructor. More...
 
 BaseLogger (const BaseLogger &) noexcept=default
 Copy constructor. More...
 
BaseLoggeroperator= (const BaseLogger &) noexcept=default
 Copy-assign operator. More...
 
 BaseLogger (BaseLogger &&) noexcept=default
 Move constructor. More...
 
BaseLoggeroperator= (BaseLogger &&) noexcept=default
 Move-assign operator. More...
 
RecordBuilder_t operator() ()
 Creates a new instance of RecordBuilder. More...
 
template<std::convertible_to< SeverityLevel_t > USeverityLevel>
void setDefaultSeverity (USeverityLevel &&sevLvl) noexcept
 Setter for the default severity level. More...
 
const SeverityLevel_tdefaultSeverity () const noexcept
 Getter for the default severity level. More...
 
template<std::convertible_to< Channel_t > UChannel>
void setDefaultChannel (UChannel &&channel) noexcept
 Setter for the default channel. More...
 
const Channel_tdefaultChannel () const noexcept
 Getter for the default channel. More...
 

Related Functions

(Note that these are not member functions.)

template<Logger TLogger, class... TArgs>
TLogger makeLogger (Core< LoggerRecord_t< TLogger >> &core, TArgs &&... args)
 Creates a Logger object and setup its callback to the given Core instance. More...
 

Detailed Description

template<Record TRecord>
class sl::log::BaseLogger< TRecord >

Convenience class for generating Record s.

Template Parameters
TRecordUsed Record type.
Attention
The corresponding Core instance must outlive all related Logger instances.

This class is in fact a template for upcoming Record s. It stores default settings (e.g. severity level and channel) for newly generated Record s. Using its operator () users can start building Record s in an effective and elegant manner. Logger instances are rather lightweight, thus could be instantiated on class level, but it is also fine using the same instance in the whole program.

Examples
CustomRecordType/main.cpp, and CustomizeBaseRecord/main.cpp.

Member Typedef Documentation

◆ Channel_t

template<Record TRecord>
using sl::log::BaseLogger< TRecord >::Channel_t = RecordChannel_t<Record_t>

◆ LogCallback_t

template<Record TRecord>
using sl::log::BaseLogger< TRecord >::LogCallback_t = std::function<void(Record_t)>

◆ Record_t

template<Record TRecord>
using sl::log::BaseLogger< TRecord >::Record_t = std::remove_cvref_t<TRecord>

◆ RecordBuilder_t

template<Record TRecord>
using sl::log::BaseLogger< TRecord >::RecordBuilder_t = RecordBuilder<Record_t>

◆ RecordSetters_t

template<Record TRecord>
using sl::log::BaseLogger< TRecord >::RecordSetters_t = RecordSetters<Record_t>

◆ SeverityLevel_t

template<Record TRecord>
using sl::log::BaseLogger< TRecord >::SeverityLevel_t = RecordSeverity_t<Record_t>

Constructor & Destructor Documentation

◆ BaseLogger() [1/3]

template<Record TRecord>
sl::log::BaseLogger< TRecord >::BaseLogger ( LogCallback_t  logCallback,
SeverityLevel_t  defaultSeverityLvl = {},
Channel_t  defaultChannel = {} 
)
inlineexplicitnoexcept

Constructor.

Creates a Logger instance and links it to the specified core instance

Parameters
logCallbackCallback which will receive created Records.
defaultSeverityLvlDefault severity level for generated Records.
defaultChannelDefault channel for generated Records.

◆ ~BaseLogger()

template<Record TRecord>
sl::log::BaseLogger< TRecord >::~BaseLogger ( )
defaultnoexcept

Destructor.

◆ BaseLogger() [2/3]

template<Record TRecord>
sl::log::BaseLogger< TRecord >::BaseLogger ( const BaseLogger< TRecord > &  )
defaultnoexcept

Copy constructor.

◆ BaseLogger() [3/3]

template<Record TRecord>
sl::log::BaseLogger< TRecord >::BaseLogger ( BaseLogger< TRecord > &&  )
defaultnoexcept

Move constructor.

Member Function Documentation

◆ defaultChannel()

template<Record TRecord>
const Channel_t& sl::log::BaseLogger< TRecord >::defaultChannel ( ) const
inlinenoexcept

Getter for the default channel.

Returns
Returns a const reference to the default channel.

◆ defaultSeverity()

template<Record TRecord>
const SeverityLevel_t& sl::log::BaseLogger< TRecord >::defaultSeverity ( ) const
inlinenoexcept

Getter for the default severity level.

Returns
Returns a const reference to the default severity level.

◆ operator()()

template<Record TRecord>
RecordBuilder_t sl::log::BaseLogger< TRecord >::operator() ( )
inline

Creates a new instance of RecordBuilder.

This is the entry point for producing new Record s. The returned RecordBuilder object will be pre-initialized with each values set to Logger's default, which might be overriden during the Record building process.

Returns
Newly created RecordBuilder instance.

◆ operator=() [1/2]

template<Record TRecord>
BaseLogger& sl::log::BaseLogger< TRecord >::operator= ( BaseLogger< TRecord > &&  )
defaultnoexcept

Move-assign operator.

◆ operator=() [2/2]

template<Record TRecord>
BaseLogger& sl::log::BaseLogger< TRecord >::operator= ( const BaseLogger< TRecord > &  )
defaultnoexcept

Copy-assign operator.

◆ setDefaultChannel()

template<Record TRecord>
template<std::convertible_to< Channel_t > UChannel>
void sl::log::BaseLogger< TRecord >::setDefaultChannel ( UChannel &&  channel)
inlinenoexcept

Setter for the default channel.

Parameters
channelNew default value

◆ setDefaultSeverity()

template<Record TRecord>
template<std::convertible_to< SeverityLevel_t > USeverityLevel>
void sl::log::BaseLogger< TRecord >::setDefaultSeverity ( USeverityLevel &&  sevLvl)
inlinenoexcept

Setter for the default severity level.

Parameters
sevLvlNew default value

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