StormByte-Logger 2.0.0
C++26 logger module of the StormByte suite
 
Loading...
Searching...
No Matches
StormByte::Logger::Log Class Reference

Public streaming facade for the StormByte logger. More...

#include <StormByte/logger/log.hxx>

Inheritance diagram for StormByte::Logger::Log:
Collaboration diagram for StormByte::Logger::Log:

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)
 

Detailed Description

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.

Member Typedef Documentation

◆ PointerType

Owner returned by Clone, Move and Scope.

Base's heap.

Constructor & Destructor Documentation

◆ Log() [1/4]

StormByte::Logger::Log::Log ( std::ostream &  out,
const Level &  level = Level::Info,
std::string_view  format = "[%L] %T" 
)
inline

Construct a Log writing to out.

Parameters
outOutput stream (e.g. std::cout). Must outlive this logger.
levelMinimum Level that will be emitted.
formatHeader 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.

◆ Log() [2/4]

StormByte::Logger::Log::Log ( const Log &  )
default

Copy constructor.

Note
Shares the Engine. Copies the sticky component path.

◆ Log() [3/4]

StormByte::Logger::Log::Log ( Log &&  )
defaultnoexcept

Move constructor.

◆ ~Log()

StormByte::Logger::Log::~Log ( )
overridenoexcept

Destructor.

Defined out of line so the backend is released inside the DLL.

◆ Log() [4/4]

StormByte::Logger::Log::Log ( SinkWrite  write,
SinkManip  manip,
void *  context,
const Level &  level,
std::string_view  format 
)
protected

Construct a logger that emits through caller callbacks.

Parameters
writeReceives raw bytes. May be null.
manipApplies an ostream manipulator in the caller. May be null.
contextPassed back to the callbacks. Not owned. Must outlive this logger.
levelMinimum Level that will be emitted.
formatHeader format string.

Member Function Documentation

◆ BeginPayload()

virtual bool StormByte::Logger::Log::BeginPayload ( )
protectedvirtual

Admit a numeric or narrow-text payload.

Log always admits.

Returns
false when ThreadedLog drops the payload.

Reimplemented in StormByte::Logger::ThreadedLog.

◆ Clone()

PointerType StormByte::Logger::Log::Clone ( ) const
overrideprotectedvirtual

Deep-copy this facade into a StormByte::Shared.

Returns
Pointer to the clone.

Implements StormByte::Clonable< Log >.

Reimplemented in StormByte::Logger::ThreadedLog.

◆ Color() [1/4]

virtual StormByte::Logger::Color StormByte::Logger::Log::Color ( const Level &  level) const
virtual

Get the configured color for a logging level.

Parameters
levelLevel whose color is requested.
Returns
Configured color.

Reimplemented in StormByte::Logger::ThreadedLog.

◆ Color() [2/4]

virtual Log & StormByte::Logger::Log::Color ( const Level &  level,
const StormByte::Logger::Color &  color 
)
virtual

Set the configured color for a logging level.

Parameters
levelLevel whose color is changed.
colorColor to use for that level.
Returns
Reference to this logger.

Reimplemented in StormByte::Logger::ThreadedLog.

◆ Color() [3/4]

virtual StormByte::Logger::Color StormByte::Logger::Log::Color ( std::string_view  component,
const Level &  level 
) const
virtual

Get a component color, falling back along the path then to the general color.

Parameters
componentComponent path.
levelLevel whose color is requested.
Returns
Component override or general color.

Reimplemented in StormByte::Logger::ThreadedLog.

◆ Color() [4/4]

virtual Log & StormByte::Logger::Log::Color ( std::string_view  component,
const Level &  level,
const StormByte::Logger::Color &  color 
)
virtual

Set a color override for a component path and level.

Parameters
componentComponent path.
levelLevel whose color is changed.
colorColor to use for that component and level.
Returns
Reference to this logger.

Reimplemented in StormByte::Logger::ThreadedLog.

◆ Enabled()

bool StormByte::Logger::Log::Enabled ( const Level &  level) const
noexcept

Whether level would be emitted given the print floor.

Parameters
levelLevel to test.
Returns
true if that level is at or above the floor, or is Warning/Error/Fatal.
Note
Does not open a line and does not consult throttle admission.

◆ FlushThrottle() [1/2]

virtual Log & StormByte::Logger::Log::FlushThrottle ( )
virtual

Flush dropped summaries for all throttle rules.

Returns
Reference to this logger.

Reimplemented in StormByte::Logger::ThreadedLog.

◆ FlushThrottle() [2/2]

virtual Log & StormByte::Logger::Log::FlushThrottle ( const ThrottleSpec &  spec)
virtual

Flush dropped summaries for matching throttle rules.

Parameters
specSelectors of the rules to flush.
Returns
Reference to this logger.

Reimplemented in StormByte::Logger::ThreadedLog.

◆ Format() [1/4]

virtual StormByte::String::String StormByte::Logger::Log::Format ( ) const
virtual

Get the effective current header format.

Returns
Owned copy of the temporary, component-specific or general format.

Reimplemented in StormByte::Logger::ThreadedLog.

◆ Format() [2/4]

virtual StormByte::String::String StormByte::Logger::Log::Format ( std::string_view  component) const
virtual

Get a component-specific format, falling back along the path then to general.

Parameters
componentComponent path.
Returns
Owned copy of the component format or general format.

Reimplemented in StormByte::Logger::ThreadedLog.

◆ Format() [3/4]

virtual Log & StormByte::Logger::Log::Format ( std::string_view  component,
std::string_view  format 
)
virtual

Set or remove a component-specific header format.

Parameters
componentComponent path; empty selects the general format.
formatFormat, or empty to remove the override.
Returns
Reference to this logger.

Reimplemented in StormByte::Logger::ThreadedLog.

◆ Format() [4/4]

virtual Log & StormByte::Logger::Log::Format ( std::string_view  format)
virtual

Set the header format.

Parameters
formatFormat used by default, or for the sticky path on a scoped facade.
Returns
Reference to this logger.

Reimplemented in StormByte::Logger::ThreadedLog.

◆ HasOpenOutputLine()

bool StormByte::Logger::Log::HasOpenOutputLine ( ) const
protectednoexcept

Whether output has already started for the current line.

Returns
true when the line header has been emitted.

◆ LineAdmitted()

bool StormByte::Logger::Log::LineAdmitted ( ) const
protectednoexcept

Whether the decided current line is admitted.

Returns
true when payload output is allowed.

◆ LineDecided()

bool StormByte::Logger::Log::LineDecided ( ) const
protectednoexcept

Whether throttle has already decided the current line.

Returns
true when the line decision exists.

◆ Move()

PointerType StormByte::Logger::Log::Move ( )
overrideprotectedvirtual

Move this facade into a StormByte::Shared.

Returns
Pointer to the new facade.

Implements StormByte::Clonable< Log >.

Reimplemented in StormByte::Logger::ThreadedLog.

◆ NoThrottle() [1/6]

virtual Log & StormByte::Logger::Log::NoThrottle ( )
virtual

Remove all throttle rules.

Returns
Reference to this logger.

Reimplemented in StormByte::Logger::ThreadedLog.

◆ NoThrottle() [2/6]

virtual Log & StormByte::Logger::Log::NoThrottle ( ComponentManip  component)
virtual

Remove a component-scoped rule.

Parameters
componentComponent path used as-is.
Returns
Reference to this logger.

Reimplemented in StormByte::Logger::ThreadedLog.

◆ NoThrottle() [3/6]

virtual Log & StormByte::Logger::Log::NoThrottle ( ComponentManip  component,
const Level &  level,
GroupManip  group 
)
virtual

Remove an exact component/level/group rule.

Parameters
componentComponent path used as-is.
levelLevel selector.
groupGroup selector.
Returns
Reference to this logger.

Reimplemented in StormByte::Logger::ThreadedLog.

◆ NoThrottle() [4/6]

virtual Log & StormByte::Logger::Log::NoThrottle ( const Level &  level)
virtual

Remove a level-scoped rule.

Parameters
levelLevel selector.
Returns
Reference to this logger.

Reimplemented in StormByte::Logger::ThreadedLog.

◆ NoThrottle() [5/6]

virtual Log & StormByte::Logger::Log::NoThrottle ( const ThrottleSpec &  spec)
virtual

Remove a throttle rule with the same selectors.

Parameters
specSelectors of the rule to remove.
Returns
Reference to this logger.

Reimplemented in StormByte::Logger::ThreadedLog.

◆ NoThrottle() [6/6]

virtual Log & StormByte::Logger::Log::NoThrottle ( GroupManip  group)
virtual

Remove a group-scoped rule.

Parameters
groupGroup selector.
Returns
Reference to this logger.

Reimplemented in StormByte::Logger::ThreadedLog.

◆ operator<<() [1/25]

Log & StormByte::Logger::Log::operator<< ( ColorManip  manip)
inline

Apply a configured or explicit content color.

Parameters
manipColor manipulator.
Returns
Reference to this logger.

◆ operator<<() [2/25]

Log & StormByte::Logger::Log::operator<< ( ComponentManip  manip)
inline

Push a component segment onto the current thread's stack.

Parameters
manipComponent manipulator.
Returns
Reference to this logger.

◆ operator<<() [3/25]

Log & StormByte::Logger::Log::operator<< ( const Level &  level)
inline

Set the level of the current line.

Parameters
levelLevel to emit.
Returns
Reference to this logger.

◆ operator<<() [4/25]

Log & StormByte::Logger::Log::operator<< ( const StormByte::BinaryData &  v)
inline

Stream owned bytes.

Parameters
vBinaryData. Same contract as a byte span: Base64, or HexDump when hex is active.
Returns
Reference to this logger.

◆ operator<<() [5/25]

Log & StormByte::Logger::Log::operator<< ( const StormByte::ByteSize &  v)
inline

Stream an octet count.

Parameters
vByteSize. Uses ByteSize::operator std::string.
Returns
Reference to this logger.

◆ operator<<() [6/25]

Log & StormByte::Logger::Log::operator<< ( const StormByte::CString &  v)
inline

Stream owned UTF-8 bytes.

Parameters
vBuffer owned by Base. Copied into the line buffer.
Returns
Reference to this logger.

◆ operator<<() [7/25]

Log & StormByte::Logger::Log::operator<< ( const StormByte::Size &  v)
inline

Stream a byte count.

Parameters
vSize. Uses Size::operator std::string.
Returns
Reference to this logger.

◆ operator<<() [8/25]

Log & StormByte::Logger::Log::operator<< ( const StormByte::String::String &  v)
inline

Stream owned UTF-8 text.

Parameters
vText owned by String. Copied into the line buffer.
Returns
Reference to this logger.

◆ operator<<() [9/25]

Log & StormByte::Logger::Log::operator<< ( const StormByte::String::WString &  v)
inline

Stream owned wide text.

Parameters
vText owned by String. Copied into the line buffer.
Returns
Reference to this logger.

◆ operator<<() [10/25]

Log & StormByte::Logger::Log::operator<< ( const StormByte::WCString &  v)
inline

Stream owned wide bytes.

Parameters
vBuffer owned by Base. Copied into the line buffer.
Returns
Reference to this logger.

◆ operator<<() [11/25]

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 & StormByte::Logger::Log::operator<< ( const T &  v)
inline

Stream a numeric or narrow-text payload.

Template Parameters
TArithmetic type other than wchar_t, string_view, or C string.
Parameters
vValue to write.
Returns
Reference to this logger.

◆ operator<<() [12/25]

Log & StormByte::Logger::Log::operator<< ( const wchar_t *  v)
inline

Stream a wide C string.

Parameters
vText to write; may be null.
Returns
Reference to this logger.

◆ operator<<() [13/25]

Log & StormByte::Logger::Log::operator<< ( FormatManip  manip)
inline

Save the current format and activate a temporary format.

Parameters
manipFormat manipulator.
Returns
Reference to this logger.

◆ operator<<() [14/25]

Log & StormByte::Logger::Log::operator<< ( GroupManip  manip)
inline

Set the producer group for the current line.

Parameters
manipGroup manipulator.
Returns
Reference to this logger.

◆ operator<<() [15/25]

Log & StormByte::Logger::Log::operator<< ( HexManip  m)
inline

Dump subsequent payloads as hex bytes until nohex.

Parameters
mHex manipulator.
Returns
Reference to this logger.

◆ operator<<() [16/25]

Log & StormByte::Logger::Log::operator<< ( Log &(*)(Log &) noexcept  manip)
inline

Apply a Log manipulator.

Parameters
manipLogger manipulator.
Returns
Reference to this logger.

◆ operator<<() [17/25]

Log & StormByte::Logger::Log::operator<< ( NoColorManip  manip)
inline

Disable color for subsequent content.

Parameters
manipNo-color manipulator.
Returns
Reference to this logger.

◆ operator<<() [18/25]

Log & StormByte::Logger::Log::operator<< ( NoHexManip  m)
inline

Disable hex dumps.

Parameters
mNo-hex manipulator.
Returns
Reference to this logger.

◆ operator<<() [19/25]

Log & StormByte::Logger::Log::operator<< ( PopComponentManip  manip)
inline

Pop one component segment from the current thread's stack.

Parameters
manipPop-component manipulator.
Returns
Reference to this logger.

◆ operator<<() [20/25]

Log & StormByte::Logger::Log::operator<< ( PopFormatManip  manip)
inline

Restore the most recently saved format.

Parameters
manipPop-format manipulator.
Returns
Reference to this logger.

◆ operator<<() [21/25]

Log & StormByte::Logger::Log::operator<< ( RedactManip  m)
inline

Apply redaction policy.

Parameters
mRedaction manipulator.
Returns
Reference to this logger.

◆ operator<<() [22/25]

Log & StormByte::Logger::Log::operator<< ( ResetComponentManip  manip)
inline

Clear the current thread's component stack.

Parameters
manipReset-component manipulator.
Returns
Reference to this logger.

◆ operator<<() [23/25]

Log & StormByte::Logger::Log::operator<< ( std::ostream &(*)(std::ostream &)  manip)
inline

Apply a stream manipulator (e.g.

std::endl).

Parameters
manipStream manipulator.
Returns
Reference to this logger.

◆ operator<<() [24/25]

Log & StormByte::Logger::Log::operator<< ( std::span< const std::byte >  v)
inline

Stream raw bytes.

Parameters
vContiguous bytes. std::vector<std::byte> converts to this span.
Returns
Reference to this logger.

◆ operator<<() [25/25]

Log & StormByte::Logger::Log::operator<< ( std::wstring_view  v)
inline

Stream wide text.

std::wstring converts to this view.

Parameters
vWide text to write.
Returns
Reference to this logger.

◆ operator=() [1/2]

Log & StormByte::Logger::Log::operator= ( const Log &  )

Copy assignment.

Defined out of line so the previous backend is released inside the DLL.

Returns
Reference to this logger.
Note
Shares the Engine. Copies the sticky component path.

◆ operator=() [2/2]

Log & StormByte::Logger::Log::operator= ( Log &&  )
noexcept

Move assignment.

Defined out of line so the previous backend is released inside the DLL.

Returns
Reference to this logger.

◆ PrepareLine()

bool StormByte::Logger::Log::PrepareLine ( )
protected

Decide throttle admission before a payload claims a line lock.

Returns
true when the current line may emit.

◆ Scope()

PointerType StormByte::Logger::Log::Scope ( std::string_view  path)

Another facade on the same backend, with a sticky component path.

Parameters
pathSegment relative to this facade, or a /-separated path.
Returns
StormByte::Shared of a Log (ThreadedLog if *this is one). Never null.
Note
Does not register the component and does not preconfigure Format, Color or Throttle. An empty path returns a clone of this facade.

◆ Throttle() [1/7]

virtual Log & StormByte::Logger::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 
)
virtual

Install an exact component/level/group rule.

Parameters
componentComponent path used as-is.
levelLevel selector.
groupGroup selector.
rateLines per second.
burstToken capacity.
policyCount policy.
valueSampleN or WindowKeep.
periodWindowPeriod when policy is Window.
Returns
Reference to this logger.

Reimplemented in StormByte::Logger::ThreadedLog.

◆ Throttle() [2/7]

virtual Log & StormByte::Logger::Log::Throttle ( ComponentManip  component,
double  rate,
std::size_t  burst 
)
virtual

Install a component-scoped Drop rule.

Parameters
componentComponent path used as-is.
rateLines per second.
burstToken capacity.
Returns
Reference to this logger.

Reimplemented in StormByte::Logger::ThreadedLog.

◆ Throttle() [3/7]

virtual Log & StormByte::Logger::Log::Throttle ( const Level &  level,
double  rate,
std::size_t  burst 
)
virtual

Install a level-scoped Drop rule.

Parameters
levelLevel selector.
rateLines per second.
burstToken capacity.
Returns
Reference to this logger.

Reimplemented in StormByte::Logger::ThreadedLog.

◆ Throttle() [4/7]

virtual Log & StormByte::Logger::Log::Throttle ( const ThrottleSpec &  spec)
virtual

Install a throttle rule.

Parameters
specRule to install. An absent Component uses the sticky path when this facade is scoped.
Returns
Reference to this logger.

Reimplemented in StormByte::Logger::ThreadedLog.

◆ Throttle() [5/7]

virtual Log & StormByte::Logger::Log::Throttle ( double  rate,
std::size_t  burst 
)
virtual

Install a Drop rule.

Parameters
rateLines per second; zero disables refill.
burstInitial and maximum token capacity.
Returns
Reference to this logger.

Reimplemented in StormByte::Logger::ThreadedLog.

◆ Throttle() [6/7]

virtual Log & StormByte::Logger::Log::Throttle ( double  rate,
std::size_t  burst,
ThrottlePolicy  policy,
std::size_t  value,
std::size_t  period = 0 
)
virtual

Install a Sample or Window rule.

Parameters
rateLines per second; zero disables refill.
burstInitial and maximum token capacity.
policySample or Window.
valueSampleN or WindowKeep.
periodWindowPeriod when policy is Window.
Returns
Reference to this logger.

Reimplemented in StormByte::Logger::ThreadedLog.

◆ Throttle() [7/7]

virtual Log & StormByte::Logger::Log::Throttle ( GroupManip  group,
double  rate,
std::size_t  burst 
)
virtual

Install a group-scoped Drop rule.

Parameters
groupGroup selector.
rateLines per second.
burstToken capacity.
Returns
Reference to this logger.

Reimplemented in StormByte::Logger::ThreadedLog.

◆ WillWrite()

bool StormByte::Logger::Log::WillWrite ( ) const
protectednoexcept

Whether the current line level will be written.

Returns
true if the current level is at or above the print floor.

◆ Write() [1/17]

virtual void StormByte::Logger::Log::Write ( ColorManip  manip)
protectedvirtual

Forward a color manipulator.

Parameters
manipColor manipulator.

Reimplemented in StormByte::Logger::ThreadedLog.

◆ Write() [2/17]

virtual void StormByte::Logger::Log::Write ( ComponentManip  manip)
protectedvirtual

Forward a component push manipulator.

Parameters
manipComponent manipulator.

◆ Write() [3/17]

virtual void StormByte::Logger::Log::Write ( const Level &  level)
protectedvirtual

Forward a level change.

Parameters
levelLevel of the current line.

Reimplemented in StormByte::Logger::ThreadedLog.

◆ Write() [4/17]

virtual void StormByte::Logger::Log::Write ( const wchar_t *  v)
protectedvirtual

Forward a wide C string.

Parameters
vText to write; may be null.

Reimplemented in StormByte::Logger::ThreadedLog.

◆ Write() [5/17]

virtual void StormByte::Logger::Log::Write ( FormatManip  manip)
protectedvirtual

Forward a push-format manipulator.

Parameters
manipFormat manipulator.

Reimplemented in StormByte::Logger::ThreadedLog.

◆ Write() [6/17]

virtual void StormByte::Logger::Log::Write ( GroupManip  manip)
protectedvirtual

Forward a group manipulator.

Parameters
manipGroup manipulator.

◆ Write() [7/17]

virtual void StormByte::Logger::Log::Write ( HexManip  m)
protectedvirtual

Forward hex-dump state.

Parameters
mHex manipulator.

Reimplemented in StormByte::Logger::ThreadedLog.

◆ Write() [8/17]

virtual void StormByte::Logger::Log::Write ( Log &(*)(Log &) noexcept  manip)
protectedvirtual

Forward a Log manipulator.

Parameters
manipLogger manipulator.

Reimplemented in StormByte::Logger::ThreadedLog.

◆ Write() [9/17]

virtual void StormByte::Logger::Log::Write ( NoColorManip  manip)
protectedvirtual

Forward a no-color manipulator.

Parameters
manipNo-color manipulator.

Reimplemented in StormByte::Logger::ThreadedLog.

◆ Write() [10/17]

virtual void StormByte::Logger::Log::Write ( NoHexManip  m)
protectedvirtual

Forward hex-dump disable.

Parameters
mNo-hex manipulator.

Reimplemented in StormByte::Logger::ThreadedLog.

◆ Write() [11/17]

virtual void StormByte::Logger::Log::Write ( PopComponentManip  manip)
protectedvirtual

Forward a component pop manipulator.

Parameters
manipPop-component manipulator.

◆ Write() [12/17]

virtual void StormByte::Logger::Log::Write ( PopFormatManip  manip)
protectedvirtual

Forward a pop-format manipulator.

Parameters
manipPop-format manipulator.

Reimplemented in StormByte::Logger::ThreadedLog.

◆ Write() [13/17]

virtual void StormByte::Logger::Log::Write ( RedactManip  m)
protectedvirtual

Forward redaction state.

Parameters
mRedaction manipulator.

Reimplemented in StormByte::Logger::ThreadedLog.

◆ Write() [14/17]

virtual void StormByte::Logger::Log::Write ( ResetComponentManip  manip)
protectedvirtual

Forward a reset-component manipulator.

Parameters
manipReset-component manipulator.

◆ Write() [15/17]

virtual void StormByte::Logger::Log::Write ( std::ostream &(*)(std::ostream &)  manip)
protectedvirtual

Forward a stream manipulator.

Parameters
manipStream manipulator.

Reimplemented in StormByte::Logger::ThreadedLog.

◆ Write() [16/17]

virtual void StormByte::Logger::Log::Write ( std::span< const std::byte >  v)
protectedvirtual

Forward raw bytes.

Parameters
vContiguous bytes to format as Base64 or hex.

Reimplemented in StormByte::Logger::ThreadedLog.

◆ Write() [17/17]

virtual void StormByte::Logger::Log::Write ( std::wstring_view  v)
protectedvirtual

Forward wide text.

Parameters
vText to write.

Reimplemented in StormByte::Logger::ThreadedLog.

◆ WriteValue()

template<typename T >
void StormByte::Logger::Log::WriteValue ( const T &  v)
protected

Forward a payload after BeginPayload.

Template Parameters
TType accepted by Engine::operator<<.
Parameters
vValue to write.

Friends And Related Symbol Documentation

◆ humanreadable_bytes

Log & humanreadable_bytes ( Log &  log)
friend

Enable human-readable formatting for byte counts.

Parameters
logThe Log instance to modify.
Returns
Reference to the same Log.

◆ humanreadable_number

Log & humanreadable_number ( Log &  log)
friend

Enable human-readable formatting for numeric values.

Parameters
logThe Log instance to modify.
Returns
Reference to the same Log.

◆ nohumanreadable

Log & nohumanreadable ( Log &  log)
friend

Disable human-readable formatting (raw numbers).

Parameters
logThe Log instance to modify.
Returns
Reference to the same Log.

◆ noredact

Log & noredact ( Log &  log)
friend

Disable redaction until the next redact / redact(n) / redact_first(n).

Parameters
logThe Log instance to modify.
Returns
Reference to the same Log.

Member Data Documentation

◆ m_engine

std::shared_ptr<Engine> StormByte::Logger::Log::m_engine
protected

Shared backend.

◆ m_scope_path

StormByte::String::String StormByte::Logger::Log::m_scope_path
protected

Sticky component path; empty = root facade.


The documentation for this class was generated from the following file: