Records are basically a collection of information, which has been gathered either implicitly or explicitly while a logging Message was created. It is not intended that users ever use a plain Record or set it up by theirselves. The library provides a simple interface which does all the trivial part of a logging step, while users can concentrate on setting up their message.
Have a look at Logger and RecordBuilder if you want to know more about how to setup Records.
22 inline std::ostream&
operator <<(std::ostream& out, Channel lvl)
24 constexpr
const char* str[] = {
"standard",
"network",
"stats" };
25 out << str[static_cast<std::size_t>(lvl)];
38 inline auto gLog = makeLogger<Logger_t>(
gCore, SevLvl::info, Channel::standard);
46 wrappedSink->setFilter(makeChannelFilterFor<Record_t>(
Equals{ Channel::network }));
48 wrappedSink->setFormatter(
51 std::stringstream out;
52 out << record.channel() <<
" >> " << record.message();
53 return std::move(out).str();
63 gLog() <<
"Hello, World!";
64 gLog() <<
SetChan(Channel::network) <<
"Hello, Network!";
Convenience class for generating Record s.
Definition: Logger.hpp:84
A collection of logging related information.
Definition: Record.hpp:227
Sink class for directly logging onto std::cout.
Definition: ConsoleSink.hpp:239
The central point of the whole library. Needs to be instantiated at least once.
Definition: Core.hpp:51
requires std::constructible_from< TSink, TArgs... > ScopedSinkDisabling< Record_t, TSink > makeDisabledSink(TArgs &&... args)
Creates Sink disabled and registers it at this Core instance.
Definition: Core.hpp:149
Compares equality with constant at invocation.
Definition: Predicates.hpp:25
Class for logging into files.
Definition: FileSink.hpp:81
Manipulates the channel of the current RecordBuilder object.
Definition: RecordBuilder.hpp:70
std::ostream & operator<<(std::ostream &out, const ConsoleTextStyle &style)
Operator << overload for ConsoleTextStyle type.
Definition: ConsoleSink.hpp:135
ConsoleSink< Record_t > ConsoleSink_t
Type alias for log::ConsoleSink which uses preset::Record_t as Record type.
Definition: PresetTypes.hpp:80
SevLvl
A simple severity level enum type.
Definition: PresetTypes.hpp:26
Core< Record_t > Core_t
Type alias for log::Core which uses preset::Record_t as Record type.
Definition: PresetTypes.hpp:56
BaseLogger< Record_t > Logger_t
Type alias for log::Logger which uses preset::Record_t as Record type.
Definition: PresetTypes.hpp:60
BaseRecord< SevLvl, std::string > Record_t
Prepared Record type.
Definition: PresetTypes.hpp:52
FileSink< Record_t > FileSink_t
Type alias for log::FileSink which uses preset::Record_t as Record type.
Definition: PresetTypes.hpp:76
auto gLog
Definition: ReadyToGo.hpp:20
Core_t gCore
Definition: ReadyToGo.hpp:18
auto & gConsoleSink
Definition: ReadyToGo.hpp:19
Definition: BasicSink.hpp:22
If your needs are more specific and you want to add things such as custom properties to the Record type, this might be an example for you:
14 class MyCustomRecord :
18 using Domain_t = std::string;
35 using Domain_t = MyCustomRecord::Domain_t;
37 explicit SetDomain(Domain_t data) :
38 m_Data{ std::move(data) }
42 void operator ()(MyCustomRecord& rec)
44 rec.domain = std::move(m_Data);
52 inline auto gLog = makeLogger<Logger_t>(
gCore, SevLvl::info);
60 wrappedSink->setFormatter(
61 [](
const MyCustomRecord& record)
63 std::stringstream out;
64 out << record.domain <<
" >> " << record.message();
65 return std::move(out).str();
75 gLog() <<
"Hello, World!";
77 gLog() << SetDomain(
"palindrome") <<
"A Man, A Plan, A Canal, Panama!";
Helper class for building new Records.
Definition: RecordBuilder.hpp:110