6 #ifndef SL_LOG_LOGGER_HPP
7 #define SL_LOG_LOGGER_HPP
19 #ifdef __cpp_lib_source_location
20 #include <source_location>
40 template <
class TLogger>
52 template <
class TLogger>
70 Record<LoggerRecord_t<T>> &&
71 std::is_invocable_r_v<RecordBuilder<LoggerRecord_t<T>>, T>;
82 template <Record TRecord>
105 m_LogCallback{ std::move(logCallback) },
106 m_DefaultSeverityLvl{ std::move(defaultSeverityLvl) },
141 #ifdef __cpp_lib_source_location
147 assert(m_LogCallback !=
nullptr &&
"Log callback must be set.");
154 #ifdef __cpp_lib_source_location
155 builder.record().sourceLocation = srcLoc;
165 template <std::convertible_to<SeverityLevel_t> USeverityLevel>
168 m_DefaultSeverityLvl = std::forward<USeverityLevel>(sevLvl);
178 return m_DefaultSeverityLvl;
185 template <std::convertible_to<Channel_t> UChannel>
188 m_DefaultChannel = std::forward<UChannel>(channel);
198 return m_DefaultChannel;
218 template <
Logger TLogger,
class... TArgs>
224 core.log(std::move(rec));
226 std::forward<TArgs>(args)...
Convenience class for generating Record s.
Definition: Logger.hpp:84
RecordChannel_t< Record_t > Channel_t
Definition: Logger.hpp:89
RecordBuilder_t operator()()
Creates a new instance of RecordBuilder.
Definition: Logger.hpp:144
void setDefaultSeverity(USeverityLevel &&sevLvl) noexcept
Setter for the default severity level.
Definition: Logger.hpp:166
std::function< void(Record_t)> LogCallback_t
Definition: Logger.hpp:91
const Channel_t & defaultChannel() const noexcept
Getter for the default channel.
Definition: Logger.hpp:196
const SeverityLevel_t & defaultSeverity() const noexcept
Getter for the default severity level.
Definition: Logger.hpp:176
RecordSeverity_t< Record_t > SeverityLevel_t
Definition: Logger.hpp:88
BaseLogger(LogCallback_t logCallback, SeverityLevel_t defaultSeverityLvl={}, Channel_t defaultChannel={}) noexcept
Constructor.
Definition: Logger.hpp:100
void setDefaultChannel(UChannel &&channel) noexcept
Setter for the default channel.
Definition: Logger.hpp:186
~BaseLogger() noexcept=default
Destructor.
std::remove_cvref_t< TRecord > Record_t
Definition: Logger.hpp:86
The central point of the whole library. Needs to be instantiated at least once.
Definition: Core.hpp:51
Helper class for building new Records.
Definition: RecordBuilder.hpp:110
typename LoggerTypedefs< TLogger >::Record_t LoggerRecord_t
Typedef for easier access to Logger's Record type.
Definition: Logger.hpp:59
concept Logger
Concept for Logger classes.
Definition: Logger.hpp:65
TLogger makeLogger(Core< LoggerRecord_t< TLogger >> &core, TArgs &&... args)
Creates a Logger object and setup its callback to the given Core instance.
Definition: Logger.hpp:219
BaseRecord< SevLvl, std::string > Record_t
Prepared Record type.
Definition: PresetTypes.hpp:52
typename RecordTypedefs< TRecord >::Severity_t RecordSeverity_t
Typedef for easier access to Record's severity type.
Definition: Record.hpp:69
typename RecordTypedefs< TRecord >::Channel_t RecordChannel_t
Typedef for easier access to Record's channel type.
Definition: Record.hpp:81
Definition: BasicSink.hpp:22
Provides a layer of abstraction to Record member types.
Definition: Logger.hpp:42
typename TLogger::Record_t Record_t
Definition: Logger.hpp:43
Provides a layer of abstraction to Record member setter.
Definition: Record.hpp:149
constexpr static auto setSeverity
Definition: Record.hpp:161
constexpr static auto setChannel
Definition: Record.hpp:169
constexpr static auto setTimePoint
Definition: Record.hpp:177