|
StormByte C++ Library: Logger module 1.2.0
StormByte-Logger is the logging module of the StormByte C++ suite.
|
Thread-safe logging facade. More...
#include <StormByte/logger/threaded_log.hxx>


Public Member Functions | |
| ThreadedLog (std::ostream &out, const Level &level=Level::Info, const std::string &format="[%L] %T") | |
Construct a ThreadedLog writing to out. | |
| ThreadedLog (const ThreadedLog &)=default | |
| Copy constructor. | |
| ThreadedLog (ThreadedLog &&) noexcept=default | |
| Move constructor. | |
| ~ThreadedLog () noexcept override=default | |
| Destructor. | |
| ThreadedLog & | operator= (const ThreadedLog &)=default |
| Copy assignment. | |
| ThreadedLog & | operator= (ThreadedLog &&) noexcept=default |
| Move assignment. | |
| Log & | Color (const Level &level, const StormByte::Logger::Color &color) override |
| Set a level color while holding the line lock. | |
| StormByte::Logger::Color | Color (const Level &level) const override |
| Get the configured color for a logging level. | |
| Log & | Color (const std::string &component, const Level &level, const StormByte::Logger::Color &color) override |
| Set a component color override under the line lock. | |
| StormByte::Logger::Color | Color (const std::string &component, const Level &level) const override |
| Get a component color, falling back along the path then to the general color. | |
| Log & | Format (const std::string &format) override |
| Set the header format under the line lock. | |
| const std::string & | Format () const override |
| Get the effective current header format. | |
| Log & | Format (const std::string &component, const std::string &format) override |
| Set or remove a component-specific header format under the line lock. | |
| const std::string & | Format (const std::string &component) const override |
| Get a component-specific format, falling back along the path then to general. | |
| Log & | Throttle (const ThrottleSpec &spec) override |
| Install a throttle rule under the line lock. | |
| Log & | NoThrottle (const ThrottleSpec &spec) override |
| Remove a throttle rule under the line lock. | |
| Log & | Throttle (double rate, std::size_t burst) override |
| Install a Drop rule (global, or sticky path if scoped). | |
| Log & | Throttle (double rate, std::size_t burst, ThrottlePolicy policy, std::size_t value, std::size_t period=0) override |
| Install a Sample or Window rule (global, or sticky path if scoped). | |
| Log & | Throttle (const Level &level, double rate, std::size_t burst) override |
| Install a level-scoped Drop rule. | |
| Log & | Throttle (GroupManip group, double rate, std::size_t burst) override |
| Install a group-scoped Drop rule. | |
| Log & | Throttle (ComponentManip component, double rate, std::size_t burst) override |
| Install a component-scoped Drop rule. | |
| Log & | Throttle (ComponentManip component, const Level &level, GroupManip group, double rate, std::size_t burst, ThrottlePolicy policy=ThrottlePolicy::Drop, std::size_t value=0, std::size_t period=0) override |
| Install an exact component/level/group rule. | |
| Log & | NoThrottle () override |
| Remove all throttle rules. | |
| Log & | NoThrottle (const Level &level) override |
| Remove a level-scoped rule. | |
| Log & | NoThrottle (GroupManip group) override |
| Remove a group-scoped rule. | |
| Log & | NoThrottle (ComponentManip component) override |
| Remove a component-scoped rule. | |
| Log & | NoThrottle (ComponentManip component, const Level &level, GroupManip group) override |
| Remove an exact component/level/group rule. | |
| Log & | FlushThrottle () override |
| Flush all dropped summaries under the line lock. | |
| Log & | FlushThrottle (const ThrottleSpec &spec) override |
| Flush matching dropped summaries under the line lock. | |
Public Member Functions inherited from StormByte::Logger::Log | |
| Log (std::ostream &out, const Level &level=Level::Info, const std::string &format="[%L] %T") | |
Construct a Log writing to out. | |
| Log (const Log &)=default | |
| Copy constructor. | |
| Log (Log &&) noexcept=default | |
| Move constructor. | |
| ~Log () noexcept override=default | |
| Destructor. | |
| Log & | operator= (const Log &)=default |
| Copy assignment. | |
| Log & | operator= (Log &&) noexcept=default |
| Move assignment. | |
| PointerType | Scope (std::string path) |
| Another facade on the same backend, with a sticky component path. | |
| bool | Enabled (const Level &level) const noexcept |
Whether level would be emitted given the print floor. | |
| Log & | operator<< (bool v) |
| Log & | operator<< (char v) |
| Log & | operator<< (signed char v) |
| Log & | operator<< (unsigned char v) |
| Log & | operator<< (short v) |
| Log & | operator<< (unsigned short v) |
| Log & | operator<< (int v) |
| Log & | operator<< (unsigned int v) |
| Log & | operator<< (long v) |
| Log & | operator<< (unsigned long v) |
| Log & | operator<< (long long v) |
| Log & | operator<< (unsigned long long v) |
| Log & | operator<< (float v) |
| Log & | operator<< (double v) |
| Log & | operator<< (long double v) |
| Log & | operator<< (std::string_view v) |
| Stream UTF-8 text. | |
| Log & | operator<< (const char *v) |
| Log & | operator<< (std::wstring_view v) |
| Stream wide text. | |
| Log & | operator<< (const wchar_t *v) |
| Log & | operator<< (std::span< const std::byte > v) |
| Stream raw bytes. | |
| Log & | operator<< (const Level &level) |
| Log & | operator<< (std::ostream &(*manip)(std::ostream &)) |
| Log & | operator<< (Log &(*manip)(Log &) noexcept) |
| Log & | operator<< (RedactManip m) |
| Apply redaction policy (full or keep-last-N). | |
| Log & | operator<< (HexManip m) |
| Dump subsequent payloads as hex bytes until nohex. | |
| Log & | operator<< (NoHexManip m) |
| Disable hex dumps and restore default payload formatting. | |
| Log & | operator<< (ColorManip manip) |
| Apply a configured or explicit content color. | |
| Log & | operator<< (NoColorManip manip) |
| Disable color for subsequent content. | |
| Log & | operator<< (FormatManip manip) |
| Save the current format and activate a temporary format. | |
| Log & | operator<< (PopFormatManip manip) |
| Restore the most recently saved format. | |
| Log & | operator<< (GroupManip manip) |
| Set the producer group for the current line. | |
| Log & | operator<< (ComponentManip manip) |
| Push a component segment onto the current thread's stack. | |
| Log & | operator<< (PopComponentManip manip) |
| Pop one component segment from the current thread's stack. | |
| Log & | operator<< (ResetComponentManip manip) |
| Clear the current thread's component stack. | |
Streaming Operators | |
Same contract as Log; data overloads early-out when filtered. | |
| Log & | operator<< (bool v) |
| Log & | operator<< (char v) |
| Log & | operator<< (signed char v) |
| Log & | operator<< (unsigned char v) |
| Log & | operator<< (short v) |
| Log & | operator<< (unsigned short v) |
| Log & | operator<< (int v) |
| Log & | operator<< (unsigned int v) |
| Log & | operator<< (long v) |
| Log & | operator<< (unsigned long v) |
| Log & | operator<< (long long v) |
| Log & | operator<< (unsigned long long v) |
| Log & | operator<< (float v) |
| Log & | operator<< (double v) |
| Log & | operator<< (long double v) |
| Log & | operator<< (std::string_view v) |
| Stream UTF-8 text. | |
| Log & | operator<< (const char *v) |
| Log & | operator<< (std::wstring_view v) |
| Stream wide text. | |
| Log & | operator<< (const wchar_t *v) |
| Log & | operator<< (std::span< const std::byte > v) |
| Stream raw bytes. | |
| Log & | operator<< (const Level &level) |
| Log & | operator<< (std::ostream &(*manip)(std::ostream &)) |
| Log & | operator<< (Log &(*manip)(Log &) noexcept) |
| Log & | operator<< (RedactManip m) |
| Apply redaction policy. | |
| Log & | operator<< (HexManip m) |
| Dump subsequent payloads as hex bytes until nohex. | |
| Log & | operator<< (NoHexManip m) |
| Disable hex dumps and restore default payload formatting. | |
| Log & | operator<< (ColorManip manip) |
| Apply a configured or explicit content color. | |
| Log & | operator<< (NoColorManip manip) |
| Disable color for subsequent content. | |
| Log & | operator<< (FormatManip manip) |
| Save and activate a temporary format under the line lock. | |
| Log & | operator<< (PopFormatManip manip) |
| Restore a saved format under the line lock. | |
| Log & | operator<< (GroupManip manip) |
| Set the producer group for the current line under the line lock. | |
| Log & | operator<< (ComponentManip manip) |
| Push a component segment onto the current thread's stack. | |
| Log & | operator<< (PopComponentManip manip) |
| Pop one component segment from the current thread's stack. | |
| Log & | operator<< (ResetComponentManip manip) |
| Clear the current thread's component stack. | |
| PointerType | Clone () const override |
| Deep-copy this facade into a shared_ptr. | |
| PointerType | Move () override |
| Move this facade into a shared_ptr. | |
Additional Inherited Members | |
Public Types inherited from StormByte::Logger::Log | |
| using | PointerType = StormByte::Clonable< Log, std::shared_ptr< Log > >::PointerType |
Smart pointer returned by Clone, Move and Scope. | |
Protected Member Functions inherited from StormByte::Logger::Log | |
| bool | WillWrite () const noexcept |
| Whether the current line level will be written. | |
| bool | PrepareLine () |
| Decide throttle admission before a payload claims a line lock. | |
| bool | HasOpenOutputLine () const noexcept |
| Whether output has already started for the current line. | |
| bool | LineDecided () const noexcept |
| Whether throttle has already decided the current line. | |
| bool | LineAdmitted () const noexcept |
| Whether the decided current line is admitted. | |
| PointerType | Clone () const override |
| Deep-copy this facade into a shared_ptr. | |
| PointerType | Move () override |
| Move this facade into a shared_ptr. | |
Protected Attributes inherited from StormByte::Logger::Log | |
| std::shared_ptr< Implementation > | m_impl |
| Shared backend (copies of Log share it) | |
| std::string | m_scope_path |
| Sticky component path; empty = root facade. | |
Thread-safe logging facade.
Serializes logical lines (until a newline manipulator) so concurrent writers do not interleave. Filtered messages do not hold the line lock. Text payloads use std::string_view / std::wstring_view like Log. Binary payloads use std::span<const std::byte> (Base64 by default).
Scope clones this type and shares both the Implementation and the line lock. The sticky component path is copied onto the clone.
| StormByte::Logger::ThreadedLog::ThreadedLog | ( | std::ostream & | out, |
| const Level & | level = Level::Info, |
||
| const std::string & | format = "[%L] %T" |
||
| ) |
Construct a ThreadedLog writing to out.
| out | Output stream. |
| level | Minimum Level that will be emitted. |
| format | Header format string (L, T, i, c, g). |
|
default |
Copy constructor.
|
defaultnoexcept |
Move constructor.
|
overridedefaultnoexcept |
Destructor.
|
overrideprotected |
Deep-copy this facade into a shared_ptr.
|
overridevirtual |
Get the configured color for a logging level.
| level | Level whose color is requested. |
Reimplemented from StormByte::Logger::Log.
|
overridevirtual |
Set a level color while holding the line lock.
| level | Level whose color is changed. |
| color | Color to use for that level. |
Reimplemented from StormByte::Logger::Log.
|
overridevirtual |
Get a component color, falling back along the path then to the general color.
| component | Component path. |
| level | Level whose color is requested. |
Reimplemented from StormByte::Logger::Log.
|
overridevirtual |
Set a component color override under the line lock.
| component | Component path. |
| level | Level whose color is changed. |
| color | Color to use for that component and level. |
Reimplemented from StormByte::Logger::Log.
|
overridevirtual |
Flush all dropped summaries under the line lock.
Reimplemented from StormByte::Logger::Log.
|
overridevirtual |
Flush matching dropped summaries under the line lock.
| spec | Selectors of the rules to flush. |
Reimplemented from StormByte::Logger::Log.
|
overridevirtual |
Get the effective current header format.
Reimplemented from StormByte::Logger::Log.
|
overridevirtual |
Get a component-specific format, falling back along the path then to general.
| component | Component path. |
Reimplemented from StormByte::Logger::Log.
|
overridevirtual |
Set or remove a component-specific header format under the line lock.
| component | Component path. |
| format | Format, or empty to remove the override. |
Reimplemented from StormByte::Logger::Log.
|
overridevirtual |
Set the header format under the line lock.
| format | Format used by default, or for the sticky path on a scoped facade. |
Reimplemented from StormByte::Logger::Log.
|
overrideprotected |
Move this facade into a shared_ptr.
|
overridevirtual |
Remove all throttle rules.
Reimplemented from StormByte::Logger::Log.
|
overridevirtual |
Remove a component-scoped rule.
The manipulator path is used as-is.
| component | Component path. |
Reimplemented from StormByte::Logger::Log.
|
overridevirtual |
Remove an exact component/level/group rule.
| component | Component path used as-is. |
| level | Level selector. |
| group | Group selector. |
Reimplemented from StormByte::Logger::Log.
Remove a level-scoped rule.
| level | Level selector. |
Reimplemented from StormByte::Logger::Log.
|
overridevirtual |
Remove a throttle rule under the line lock.
| spec | Selectors of the rule to remove. |
Reimplemented from StormByte::Logger::Log.
|
overridevirtual |
Remove a group-scoped rule.
| group | Group selector. |
Reimplemented from StormByte::Logger::Log.
|
inline |
|
inline |
|
inline |
Apply a configured or explicit content color.
| manip | Color manipulator. |
|
inline |
Push a component segment onto the current thread's stack.
| manip | Component manipulator. |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Save and activate a temporary format under the line lock.
| manip | Format manipulator. |
|
inline |
Set the producer group for the current line under the line lock.
| manip | Group manipulator. |
Dump subsequent payloads as hex bytes until nohex.
| m | Hex manipulator. |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Disable color for subsequent content.
| manip | No-color manipulator. |
|
inline |
Disable hex dumps and restore default payload formatting.
| m | No-hex manipulator. |
|
inline |
Pop one component segment from the current thread's stack.
| manip | Pop-component manipulator. |
|
inline |
Restore a saved format under the line lock.
| manip | Pop-format manipulator. |
|
inline |
Apply redaction policy.
State remains until noredact.
| m | Redaction manipulator. |
|
inline |
Clear the current thread's component stack.
| manip | Reset-component manipulator. |
|
inline |
|
inline |
|
inline |
|
inline |
Stream raw bytes.
Default output is Base64; hex dumps 0xHH.
| v | Contiguous bytes. std::vector<std::byte> converts to this span. |
|
inline |
Stream UTF-8 text.
std::string converts to this view.
| v | Text to write. |
|
inline |
Stream wide text.
std::wstring converts to this view.
| v | Wide text to write. |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
default |
Copy assignment.
|
defaultnoexcept |
Move assignment.
|
overridevirtual |
Install an exact component/level/group rule.
| component | Component path used as-is. |
| level | Level selector. |
| group | Group selector. |
| rate | Lines per second. |
| burst | Token capacity. |
| policy | Count policy. |
| value | SampleN or WindowKeep. |
| period | WindowPeriod when policy is Window. |
Reimplemented from StormByte::Logger::Log.
|
overridevirtual |
Install a component-scoped Drop rule.
The manipulator path is used as-is.
| component | Component path. |
| rate | Lines per second. |
| burst | Token capacity. |
Reimplemented from StormByte::Logger::Log.
|
overridevirtual |
Install a level-scoped Drop rule.
| level | Level selector. |
| rate | Lines per second. |
| burst | Token capacity. |
Reimplemented from StormByte::Logger::Log.
|
overridevirtual |
Install a throttle rule under the line lock.
| spec | Rule to install. An absent Component uses the sticky path when scoped. |
Reimplemented from StormByte::Logger::Log.
|
overridevirtual |
Install a Drop rule (global, or sticky path if scoped).
| rate | Lines per second. |
| burst | Token capacity. |
Reimplemented from StormByte::Logger::Log.
|
overridevirtual |
Install a Sample or Window rule (global, or sticky path if scoped).
| rate | Lines per second. |
| burst | Token capacity. |
| policy | Sample or Window. |
| value | SampleN or WindowKeep. |
| period | WindowPeriod when policy is Window. |
Reimplemented from StormByte::Logger::Log.
|
overridevirtual |
Install a group-scoped Drop rule.
| group | Group selector. |
| rate | Lines per second. |
| burst | Token capacity. |
Reimplemented from StormByte::Logger::Log.