|
StormByte C++ Library: Logger module 1.2.0
StormByte-Logger is the logging module of the StormByte C++ suite.
|
Public streaming facade for the StormByte logger. More...
#include <StormByte/logger/log.hxx>


Public Types | |
| using | PointerType = StormByte::Clonable< Log, std::shared_ptr< Log > >::PointerType |
Smart pointer returned by Clone, Move and Scope. | |
Public Member Functions | |
| 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. | |
| virtual Log & | Color (const Level &level, const StormByte::Logger::Color &color) |
| Set the configured color for a logging level. | |
| virtual StormByte::Logger::Color | Color (const Level &level) const |
| Get the configured color for a logging level. | |
| virtual Log & | Color (const std::string &component, const Level &level, const StormByte::Logger::Color &color) |
| Set a color override for a component path and level. | |
| virtual StormByte::Logger::Color | Color (const std::string &component, const Level &level) const |
| Get a component color, falling back along the path then to the general color. | |
| virtual Log & | Format (const std::string &format) |
| Set the header format. | |
| virtual const std::string & | Format () const |
| Get the effective current header format. | |
| virtual Log & | Format (const std::string &component, const std::string &format) |
| Set or remove a component-specific header format. | |
| virtual const std::string & | Format (const std::string &component) const |
| Get a component-specific format, falling back along the path then to general. | |
| virtual Log & | Throttle (const ThrottleSpec &spec) |
| Install a throttle rule. | |
| virtual Log & | NoThrottle (const ThrottleSpec &spec) |
| Remove a throttle rule with the same selectors. | |
| virtual Log & | Throttle (double rate, std::size_t burst) |
| Install a Drop rule. | |
| virtual Log & | Throttle (double rate, std::size_t burst, ThrottlePolicy policy, std::size_t value, std::size_t period=0) |
| Install a Sample or Window rule. | |
| virtual Log & | Throttle (const Level &level, double rate, std::size_t burst) |
| Install a level-scoped Drop rule. | |
| virtual Log & | Throttle (GroupManip group, double rate, std::size_t burst) |
| Install a group-scoped Drop rule. | |
| virtual Log & | Throttle (ComponentManip component, double rate, std::size_t burst) |
| Install a component-scoped Drop rule. | |
| virtual 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) |
| Install an exact component/level/group rule. | |
| virtual Log & | NoThrottle () |
| Remove all throttle rules. | |
| virtual Log & | NoThrottle (const Level &level) |
| Remove a level-scoped rule. | |
| virtual Log & | NoThrottle (GroupManip group) |
| Remove a group-scoped rule. | |
| virtual Log & | NoThrottle (ComponentManip component) |
| Remove a component-scoped rule. | |
| virtual Log & | NoThrottle (ComponentManip component, const Level &level, GroupManip group) |
| Remove an exact component/level/group rule. | |
| virtual Log & | FlushThrottle () |
| Flush dropped summaries for all throttle rules. | |
| virtual Log & | FlushThrottle (const ThrottleSpec &spec) |
| Flush dropped summaries for matching throttle rules. | |
Protected Member Functions | |
Write | |
Forward a value or state change to Implementation. | |
| virtual void | Write (bool v) |
| virtual void | Write (char v) |
| virtual void | Write (signed char v) |
| virtual void | Write (unsigned char v) |
| virtual void | Write (short v) |
| virtual void | Write (unsigned short v) |
| virtual void | Write (int v) |
| virtual void | Write (unsigned int v) |
| virtual void | Write (long v) |
| virtual void | Write (unsigned long v) |
| virtual void | Write (long long v) |
| virtual void | Write (unsigned long long v) |
| virtual void | Write (float v) |
| virtual void | Write (double v) |
| virtual void | Write (long double v) |
| virtual void | Write (std::string_view v) |
| virtual void | Write (const char *v) |
| virtual void | Write (std::wstring_view v) |
| virtual void | Write (const wchar_t *v) |
| virtual void | Write (std::span< const std::byte > v) |
| Forward raw bytes to the implementation. | |
| virtual void | Write (const Level &level) |
| virtual void | Write (std::ostream &(*manip)(std::ostream &)) |
| virtual void | Write (Log &(*manip)(Log &) noexcept) |
| virtual void | Write (RedactManip m) |
| Forward redaction state to the implementation. | |
| virtual void | Write (HexManip m) |
| Forward hex-dump state to the implementation. | |
| virtual void | Write (NoHexManip m) |
| Forward hex-dump disable to the implementation. | |
| virtual void | Write (ColorManip manip) |
| Forward a color manipulator. | |
| virtual void | Write (NoColorManip manip) |
| Forward a no-color manipulator. | |
| virtual void | Write (FormatManip manip) |
| Forward a push-format manipulator. | |
| virtual void | Write (PopFormatManip manip) |
| Forward a pop-format manipulator. | |
| virtual void | Write (GroupManip manip) |
| Forward a group manipulator. | |
| virtual void | Write (ComponentManip manip) |
| Forward a component push manipulator. | |
| virtual void | Write (PopComponentManip manip) |
| Forward a component pop manipulator. | |
| virtual void | Write (ResetComponentManip manip) |
| Forward a reset-component manipulator. | |
Friends | |
| Log & | humanreadable_number (Log &log) noexcept |
| Enable human-readable formatting for numeric values. | |
| Log & | humanreadable_bytes (Log &log) noexcept |
| Enable human-readable formatting for byte counts. | |
| Log & | nohumanreadable (Log &log) noexcept |
| Disable human-readable formatting (raw numbers). | |
| Log & | noredact (Log &log) noexcept |
| Disable redaction until the next redact / redact(n) / redact_first(n). | |
Streaming Operators | |
Data overloads early-out when the current message level is filtered. Level, stream manipulators, Log manipulators, RedactManip, HexManip and NoHexManip are always forwarded so logger state stays consistent. | |
| std::shared_ptr< Implementation > | m_impl |
| Shared backend (copies of Log share it) | |
| std::string | m_scope_path |
| Sticky component path; empty = root facade. | |
| 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. | |
| 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. | |
Public streaming facade for the StormByte logger.
Owns a shared_ptr to the internal Implementation and exposes operator<< overloads similar to std::ostream. Filtered levels early-out without I/O. The configured print level does not suppress Warning, Error or Fatal.
Text payloads use std::string_view / std::wstring_view. std::string and std::wstring convert to those views (no extra copy of the input). There is no separate operator<<(const std::string&).
Binary payloads use std::span<const std::byte>. A std::vector<std::byte> converts to that span. Default formatting is Base64; hex dumps the bytes.
Scope returns another facade that shares the Implementation (and, on ThreadedLog, the line lock) and carries a sticky component path. Format, Color and Throttle calls without an explicit component use that path. The root facade (empty path) still installs global rules.
The thread-local component stack (component / pop_component / reset_component) is independent of Scope. It only affects emission on the root facade.
| using StormByte::Logger::Log::PointerType = StormByte::Clonable<Log, std::shared_ptr<Log> >::PointerType |
Smart pointer returned by Clone, Move and Scope.
| StormByte::Logger::Log::Log | ( | std::ostream & | out, |
| const Level & | level = Level::Info, |
||
| const std::string & | format = "[%L] %T" |
||
| ) |
Construct a Log writing to out.
| out | Output stream (e.g. std::cout). |
| level | Minimum Level that will be emitted. |
| format | Header format: L level, T timestamp, i thread id, c component, g group, %% literal %. |
|
default |
Copy constructor.
|
defaultnoexcept |
Move constructor.
|
overridedefaultnoexcept |
Destructor.
|
overrideprotected |
Deep-copy this facade into a shared_ptr.
|
virtual |
Get the configured color for a logging level.
| level | Level whose color is requested. |
Reimplemented in StormByte::Logger::ThreadedLog.
|
virtual |
Set the configured color for a logging level.
| level | Level whose color is changed. |
| color | Color to use for that level. |
Reimplemented in StormByte::Logger::ThreadedLog.
|
virtual |
Get a component color, falling back along the path then to the general color.
| component | Component path. |
| level | Level whose color is requested. |
Reimplemented in StormByte::Logger::ThreadedLog.
|
virtual |
Set a color override for a component path and level.
| component | Component path (Multimedia or Multimedia/Decoder). |
| level | Level whose color is changed. |
| color | Color to use for that component and level. |
Reimplemented in StormByte::Logger::ThreadedLog.
|
noexcept |
Whether level would be emitted given the print floor.
| level | Level to test. |
|
virtual |
Flush dropped summaries for all throttle rules.
Reimplemented in StormByte::Logger::ThreadedLog.
|
virtual |
Flush dropped summaries for matching throttle rules.
| spec | Selectors of the rules to flush. |
Reimplemented in StormByte::Logger::ThreadedLog.
|
virtual |
Get the effective current header format.
Reimplemented in StormByte::Logger::ThreadedLog.
|
virtual |
Get a component-specific format, falling back along the path then to general.
| component | Component path. |
Reimplemented in StormByte::Logger::ThreadedLog.
|
virtual |
Set or remove a component-specific header format.
| component | Component path; empty selects the general format. |
| format | Format, or empty to remove the override. |
Reimplemented in StormByte::Logger::ThreadedLog.
|
virtual |
Set the header format.
| format | Format used by default, or for the sticky path on a scoped facade. |
Reimplemented in StormByte::Logger::ThreadedLog.
|
protectednoexcept |
Whether output has already started for the current line.
|
protectednoexcept |
Whether the decided current line is admitted.
|
protectednoexcept |
Whether throttle has already decided the current line.
|
overrideprotected |
Move this facade into a shared_ptr.
|
virtual |
Remove all throttle rules.
Reimplemented in StormByte::Logger::ThreadedLog.
|
virtual |
Remove a component-scoped rule.
| component | Component path used as-is. |
Reimplemented in StormByte::Logger::ThreadedLog.
|
virtual |
Remove an exact component/level/group rule.
| component | Component path used as-is. |
| level | Level selector. |
| group | Group selector. |
Reimplemented in StormByte::Logger::ThreadedLog.
Remove a level-scoped rule.
| level | Level selector. |
Reimplemented in StormByte::Logger::ThreadedLog.
|
virtual |
Remove a throttle rule with the same selectors.
| spec | Selectors of the rule to remove. An absent Component uses the sticky path when scoped. |
Reimplemented in StormByte::Logger::ThreadedLog.
|
virtual |
Remove a group-scoped rule.
| group | Group selector. |
Reimplemented in StormByte::Logger::ThreadedLog.
|
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 the current format and activate a temporary format.
| manip | Format manipulator. |
|
inline |
Set the producer group for the current line.
| 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 the most recently saved format.
| manip | Pop-format manipulator. |
|
inline |
Apply redaction policy (full or keep-last-N).
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.
| v | Contiguous bytes. std::vector<std::byte> converts to this span. |
hex dumps 0xHH rows instead.
|
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 |
Copy assignment.
Move assignment.
|
protected |
Decide throttle admission before a payload claims a line lock.
| PointerType StormByte::Logger::Log::Scope | ( | std::string | path | ) |
Another facade on the same backend, with a sticky component path.
| path | Segment relative to this facade, or a /-separated path. |
path returns a clone of this facade.
|
virtual |
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 in StormByte::Logger::ThreadedLog.
|
virtual |
Install a component-scoped Drop rule.
| component | Component path used as-is (does not use the sticky path). |
| rate | Lines per second. |
| burst | Token capacity. |
Reimplemented in StormByte::Logger::ThreadedLog.
|
virtual |
Install a level-scoped Drop rule.
| level | Level selector. |
| rate | Lines per second. |
| burst | Token capacity. |
Reimplemented in StormByte::Logger::ThreadedLog.
|
virtual |
Install a throttle rule.
| spec | Rule to install. An absent Component uses the sticky path when this facade is scoped. |
Reimplemented in StormByte::Logger::ThreadedLog.
|
virtual |
Install a Drop rule.
| rate | Lines per second; zero disables refill. |
| burst | Initial and maximum token capacity. |
Reimplemented in StormByte::Logger::ThreadedLog.
|
virtual |
Install a Sample or Window rule.
| rate | Lines per second; zero disables refill. |
| burst | Initial and maximum token capacity. |
| policy | Sample or Window. |
| value | SampleN or WindowKeep. |
| period | WindowPeriod when policy is Window. |
Reimplemented in StormByte::Logger::ThreadedLog.
|
virtual |
Install a group-scoped Drop rule.
| group | Group selector. |
| rate | Lines per second. |
| burst | Token capacity. |
Reimplemented in StormByte::Logger::ThreadedLog.
|
protectednoexcept |
Whether the current line level will be written.
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
Forward a color manipulator.
| manip | Color manipulator. |
|
protectedvirtual |
Forward a component push manipulator.
| manip | Component manipulator. |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
Forward a push-format manipulator.
| manip | Format manipulator. |
|
protectedvirtual |
Forward a group manipulator.
| manip | Group manipulator. |
|
protectedvirtual |
Forward hex-dump state to the implementation.
| m | Hex manipulator. |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
Forward a no-color manipulator.
| manip | No-color manipulator. |
|
protectedvirtual |
Forward hex-dump disable to the implementation.
| m | No-hex manipulator. |
|
protectedvirtual |
Forward a component pop manipulator.
| manip | Pop-component manipulator. |
|
protectedvirtual |
Forward a pop-format manipulator.
| manip | Pop-format manipulator. |
|
protectedvirtual |
Forward redaction state to the implementation.
| m | Redaction manipulator. |
|
protectedvirtual |
Forward a reset-component manipulator.
| manip | Reset-component manipulator. |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
Forward raw bytes to the implementation.
| v | Contiguous bytes to format as Base64 or hex. |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protected |
Shared backend (copies of Log share it)
|
protected |
Sticky component path; empty = root facade.