Public streaming facade for the StormByte logger. More...
#include <StormByte/logger/log.hxx>


Public Types | |
| using | PointerType = StormByte::Clonable< Log >::PointerType |
| Owner returned by Clone, Move and Scope. | |
Public Member Functions | |
| Log (std::ostream &out, const Level &level=Level::Info, std::string_view format="[%L] %T") | |
| Construct a Log writing to out. | |
| Log (const Log &)=default | |
| Copy constructor. | |
| Log (Log &&) noexcept=default | |
| Move constructor. | |
| ~Log () noexcept override | |
| Destructor. | |
| Log & | operator= (const Log &) |
| Copy assignment. | |
| Log & | operator= (Log &&) noexcept |
| Move assignment. | |
| PointerType | Scope (std::string_view 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 (std::string_view component, const Level &level, const StormByte::Logger::Color &color) |
| Set a color override for a component path and level. | |
| virtual StormByte::Logger::Color | Color (std::string_view component, const Level &level) const |
| Get a component color, falling back along the path then to the general color. | |
| virtual Log & | Format (std::string_view format) |
| Set the header format. | |
| virtual StormByte::String::String | Format () const |
| Get the effective current header format. | |
| virtual Log & | Format (std::string_view component, std::string_view format) |
| Set or remove a component-specific header format. | |
| virtual StormByte::String::String | Format (std::string_view 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. | |
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 | |
| std::shared_ptr< Engine > | m_engine |
| Shared backend. | |
| StormByte::String::String | m_scope_path |
| Sticky component path; empty = root facade. | |
| template<typename T > requires ( (StormByte::Type::Arithmetic<std::decay_t<T>> && !StormByte::Type::SameAs<std::decay_t<T>, wchar_t>) || StormByte::Type::SameAs<std::decay_t<T>, std::string_view> || StormByte::Type::SameAs<std::decay_t<T>, const char*> || StormByte::Type::SameAs<std::decay_t<T>, char*> ) | |
| Log & | operator<< (const T &v) |
| Stream a numeric or narrow-text payload. | |
| Log & | operator<< (const StormByte::CString &v) |
| Stream owned UTF-8 bytes. | |
| Log & | operator<< (const StormByte::String::String &v) |
| Stream owned UTF-8 text. | |
| Log & | operator<< (std::wstring_view v) |
| Stream wide text. | |
| Log & | operator<< (const wchar_t *v) |
| Stream a wide C string. | |
| Log & | operator<< (const StormByte::WCString &v) |
| Stream owned wide bytes. | |
| Log & | operator<< (const StormByte::String::WString &v) |
| Stream owned wide text. | |
| Log & | operator<< (std::span< const std::byte > v) |
| Stream raw bytes. | |
| Log & | operator<< (const StormByte::BinaryData &v) |
| Stream owned bytes. | |
| Log & | operator<< (const StormByte::Size &v) |
| Stream a byte count. | |
| Log & | operator<< (const StormByte::ByteSize &v) |
| Stream an octet count. | |
| Log & | operator<< (const Level &level) |
| Set the level of the current line. | |
| Log & | operator<< (std::ostream &(*manip)(std::ostream &)) |
| Apply a stream manipulator (e.g. | |
| Log & | operator<< (Log &(*manip)(Log &) noexcept) |
| Apply a Log manipulator. | |
| 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. | |
| 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. | |
| Log (SinkWrite write, SinkManip manip, void *context, const Level &level, std::string_view format) | |
| Construct a logger that emits through caller callbacks. | |
| 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. | |
| virtual bool | BeginPayload () |
| Admit a numeric or narrow-text payload. | |
| template<typename T > | |
| void | WriteValue (const T &v) |
| Forward a payload after BeginPayload. | |
| PointerType | Clone () const override |
| Deep-copy this facade into a StormByte::Shared. | |
| PointerType | Move () override |
| Move this facade into a StormByte::Shared. | |
| virtual void | Write (std::wstring_view v) |
| Forward wide text. | |
| virtual void | Write (const wchar_t *v) |
| Forward a wide C string. | |
| virtual void | Write (std::span< const std::byte > v) |
| Forward raw bytes. | |
| virtual void | Write (const Level &level) |
| Forward a level change. | |
| virtual void | Write (std::ostream &(*manip)(std::ostream &)) |
| Forward a stream manipulator. | |
| virtual void | Write (Log &(*manip)(Log &) noexcept) |
| Forward a Log manipulator. | |
| virtual void | Write (RedactManip m) |
| Forward redaction state. | |
| virtual void | Write (HexManip m) |
| Forward hex-dump state. | |
| virtual void | Write (NoHexManip m) |
| Forward hex-dump disable. | |
| 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. | |
Additional Inherited Members | |
Protected Types inherited from StormByte::Clonable< Log > | |
| typedef SmartPointer | PointerType |
Protected Member Functions inherited from StormByte::Clonable< Log > | |
| constexpr | Clonable ()=default |
| constexpr | Clonable (const Clonable &)=default |
| constexpr | Clonable (Clonable &&) noexcept=default |
| constexpr Clonable & | operator= (const Clonable &)=default |
| constexpr Clonable & | operator= (Clonable &&) noexcept=default |
| virtual constexpr | ~Clonable () noexcept=default |
Static Protected Member Functions inherited from StormByte::Clonable< Log > | |
| static PointerType | MakePointer (Args &&... args) |
Public streaming facade for the StormByte logger.
Owns a shared_ptr to the internal Engine 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.
Numeric and narrow-text payloads share WriteValue after WillWrite. ThreadedLog only overrides BeginPayload for those payloads. Owned suite text has its own overloads so WillWrite runs before conversion. StormByte::Size and StormByte::ByteSize are sugar over operator std::string.
Binary payloads are std::span<const std::byte>, std::vector<std::byte> and StormByte::BinaryData. Default formatting is Base64. With hex(N) they use BinaryData::HexDump(N). Text still uses the 0xAA dump.
| using StormByte::Logger::Log::PointerType = StormByte::Clonable<Log>::PointerType |
Owner returned by Clone, Move and Scope.
Base's heap.
|
inline |
Construct a Log writing to out.
| out | Output stream (e.g. std::cout). Must outlive this logger. |
| level | Minimum Level that will be emitted. |
| format | Header format: L level, T timestamp, i thread id, c component, g group, %% literal %. |
The stream is not touched from inside the DLL. Writes jump back to OStreamWrite and OStreamManip in the module that constructs this logger.
|
default |
Copy constructor.
|
defaultnoexcept |
Move constructor.
|
overridenoexcept |
Destructor.
Defined out of line so the backend is released inside the DLL.
|
protected |
Construct a logger that emits through caller callbacks.
| write | Receives raw bytes. May be null. |
| manip | Applies an ostream manipulator in the caller. May be null. |
| context | Passed back to the callbacks. Not owned. Must outlive this logger. |
| level | Minimum Level that will be emitted. |
| format | Header format string. |
|
protectedvirtual |
Admit a numeric or narrow-text payload.
Log always admits.
Reimplemented in StormByte::Logger::ThreadedLog.
|
overrideprotectedvirtual |
Deep-copy this facade into a StormByte::Shared.
Implements StormByte::Clonable< Log >.
Reimplemented in StormByte::Logger::ThreadedLog.
|
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. |
| 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.
|
overrideprotectedvirtual |
Move this facade into a StormByte::Shared.
Implements StormByte::Clonable< Log >.
Reimplemented in StormByte::Logger::ThreadedLog.
|
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. |
Reimplemented in StormByte::Logger::ThreadedLog.
|
virtual |
Remove a group-scoped rule.
| group | Group selector. |
Reimplemented in StormByte::Logger::ThreadedLog.
|
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. |
Set the level of the current line.
| level | Level to emit. |
|
inline |
Stream owned bytes.
| v | BinaryData. Same contract as a byte span: Base64, or HexDump when hex is active. |
|
inline |
Stream an octet count.
| v | ByteSize. Uses ByteSize::operator std::string. |
|
inline |
Stream owned UTF-8 bytes.
| v | Buffer owned by Base. Copied into the line buffer. |
|
inline |
Stream a byte count.
| v | Size. Uses Size::operator std::string. |
|
inline |
Stream owned UTF-8 text.
| v | Text owned by String. Copied into the line buffer. |
|
inline |
Stream owned wide text.
| v | Text owned by String. Copied into the line buffer. |
|
inline |
Stream owned wide bytes.
| v | Buffer owned by Base. Copied into the line buffer. |
|
inline |
Stream a numeric or narrow-text payload.
| T | Arithmetic type other than wchar_t, string_view, or C string. |
| v | Value to write. |
|
inline |
Stream a wide C string.
| v | Text to write; may be null. |
|
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 |
Disable color for subsequent content.
| manip | No-color manipulator. |
|
inline |
Disable hex dumps.
| 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.
| m | Redaction manipulator. |
|
inline |
Clear the current thread's component stack.
| manip | Reset-component manipulator. |
|
inline |
Apply a stream manipulator (e.g.
std::endl).
| manip | Stream manipulator. |
|
inline |
Stream raw bytes.
| v | Contiguous bytes. std::vector<std::byte> converts to this span. |
|
inline |
Stream wide text.
std::wstring converts to this view.
| v | Wide text to write. |
Copy assignment.
Defined out of line so the previous backend is released inside the DLL.
Move assignment.
Defined out of line so the previous backend is released inside the DLL.
|
protected |
Decide throttle admission before a payload claims a line lock.
| PointerType StormByte::Logger::Log::Scope | ( | std::string_view | path | ) |
Another facade on the same backend, with a sticky component path.
| path | Segment relative to this facade, or a /-separated path. |
|
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. |
| 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 |
Forward a color manipulator.
| manip | Color manipulator. |
Reimplemented in StormByte::Logger::ThreadedLog.
|
protectedvirtual |
Forward a component push manipulator.
| manip | Component manipulator. |
|
protectedvirtual |
Forward a level change.
| level | Level of the current line. |
Reimplemented in StormByte::Logger::ThreadedLog.
|
protectedvirtual |
Forward a wide C string.
| v | Text to write; may be null. |
Reimplemented in StormByte::Logger::ThreadedLog.
|
protectedvirtual |
Forward a push-format manipulator.
| manip | Format manipulator. |
Reimplemented in StormByte::Logger::ThreadedLog.
|
protectedvirtual |
Forward a group manipulator.
| manip | Group manipulator. |
|
protectedvirtual |
Forward hex-dump state.
| m | Hex manipulator. |
Reimplemented in StormByte::Logger::ThreadedLog.
Forward a Log manipulator.
| manip | Logger manipulator. |
Reimplemented in StormByte::Logger::ThreadedLog.
|
protectedvirtual |
Forward a no-color manipulator.
| manip | No-color manipulator. |
Reimplemented in StormByte::Logger::ThreadedLog.
|
protectedvirtual |
Forward hex-dump disable.
| m | No-hex manipulator. |
Reimplemented in StormByte::Logger::ThreadedLog.
|
protectedvirtual |
Forward a component pop manipulator.
| manip | Pop-component manipulator. |
|
protectedvirtual |
Forward a pop-format manipulator.
| manip | Pop-format manipulator. |
Reimplemented in StormByte::Logger::ThreadedLog.
|
protectedvirtual |
Forward redaction state.
| m | Redaction manipulator. |
Reimplemented in StormByte::Logger::ThreadedLog.
|
protectedvirtual |
Forward a reset-component manipulator.
| manip | Reset-component manipulator. |
|
protectedvirtual |
Forward a stream manipulator.
| manip | Stream manipulator. |
Reimplemented in StormByte::Logger::ThreadedLog.
|
protectedvirtual |
Forward raw bytes.
| v | Contiguous bytes to format as Base64 or hex. |
Reimplemented in StormByte::Logger::ThreadedLog.
|
protectedvirtual |
|
protected |
Forward a payload after BeginPayload.
| T | Type accepted by Engine::operator<<. |
| v | Value to write. |
|
protected |
Shared backend.
|
protected |
Sticky component path; empty = root facade.