Simple-Log
alpha-v0.7
|
The central point of the whole library. Needs to be instantiated at least once. More...
#include <Core.hpp>
Public Types | |
using | Record_t = std::remove_cvref_t< TRecord > |
Public Member Functions | |
Core () noexcept | |
Default Constructor. More... | |
~Core () noexcept | |
Destructor. More... | |
Core (const Core &)=delete | |
Deleted copy constructor. More... | |
Core & | operator= (const Core &)=delete |
Deleted copy assign operator. More... | |
Core (Core &&)=delete | |
Deleted move constructor. More... | |
Core & | operator= (Core &&)=delete |
Deleted move assign operator. More... | |
void | log (Record_t &&record) |
Queues the Record internally. More... | |
template<std::derived_from< ISink_t > TSink, class... TArgs> | |
requires std::constructible_from< TSink, TArgs... > TSink & | makeSink (TArgs &&... args) |
Creates Sink and registers it at this Core instance. More... | |
template<std::derived_from< ISink_t > TSink, class... TArgs> | |
requires std::constructible_from< TSink, TArgs... > ScopedSinkDisabling< Record_t, TSink > | makeDisabledSink (TArgs &&... args) |
Creates Sink disabled and registers it at this Core instance. More... | |
bool | removeSink (const ISink_t &sink) |
Removes the given Sink and destroys it. More... | |
The central point of the whole library. Needs to be instantiated at least once.
TRecord | Used Record type. |
Objects of this class act like a broker between the (multiple) Logger s on the frontend and the (multiple) Sink s on the backend. Due to this there must at least one living instance of Core during the whole program runtime, but it isn't restricted to exist uniquely. It can be totally fine to create one global Core, which will be used for general logging purposes, and multiple others for a much lesser scope, like state logging on entity level. Logger will be permanently linked to one specific Core instance, thus Core instances must outlive their corresponding Logger s.
Each instance of Core consists of the following:
Due to this the Core is thread-safe by design.
It is fine to add Sinks during later stages of your program. This hasn't necessarily to be done right after Core's creation. When Core goes out of scope, or is about to get destructed otherwise, it will block any new Records which could be pushed into but will also let the Worker finish its work. Therefor it will wait in the destructor, unless there is an exception throwing, in which case Core will force the Worker to quit its work instantly.
Core instances are neither copy- nor movable.
using sl::log::Core< TRecord >::Record_t = std::remove_cvref_t<TRecord> |
|
inlinenoexcept |
Default Constructor.
The internal Worker thread will directly start running.
|
inlinenoexcept |
Destructor.
Will block until the internal Record queue is empty or an exception rises, which will then force the Worker thread to quit.
|
delete |
Deleted copy constructor.
|
delete |
Deleted move constructor.
|
inline |
Queues the Record internally.
record | The record which will be queued |
This function should not be called directly on logging purposes. It serves as a simple interface for the corresponding Logger objects.
|
inline |
Creates Sink disabled and registers it at this Core instance.
TSink | Concrete Sink type |
TArgs | Constructor argument types (will be deducted automatically) |
args | The constructor arguments for the newly generated Sink object. Will be forwarded as is. |
This function creates a new disabled Sink object and returns a wrapped reference to the caller. When this wrapper goes out of scope or gets destructed otherwise, the attached Sink will become enabled. Use this if you want to make sure, that no messages will be handled before your Sink is finally setup. This Sink will be linked to and managed by the called Core instance.
|
inline |
Creates Sink and registers it at this Core instance.
TSink | Concrete Sink type |
TArgs | Constructor argument types (will be deducted automatically) |
args | The constructor arguments for the newly generated Sink object. Will be forwarded as is. |
This function creates a new Sink object and returns a reference to the caller. This Sink will be linked to and managed by the called Core instance.
|
delete |
Deleted copy assign operator.
|
delete |
Deleted move assign operator.
|
inline |
Removes the given Sink and destroys it.
sink | The sink which will be destroyed |
If this sink is registered at this Core instance, then it will be destroyed immediately. Otherwise nothing will change.