22#include <StormByte/clonable.hxx>
25#include <StormByte/type_traits.hxx>
75 using PointerType = StormByte::Clonable<Log, std::shared_ptr<Log>>::PointerType;
83 Log(std::ostream& out,
const Level& level = Level::Info,
const std::string& format =
"[%L] %T");
99 ~
Log() noexcept override = default;
112 Log& operator=(
Log&&) noexcept = default;
129 bool Enabled(const
Level& level) const noexcept;
169 virtual
Log& Format(const std::
string& format);
175 virtual const std::
string& Format() const;
183 virtual
Log& Format(const std::
string& component, const std::
string& format);
190 virtual const std::
string& Format(const std::
string& component) const;
213 virtual
Log& Throttle(
double rate, std::
size_t burst);
225 virtual
Log& Throttle(
double rate, std::
size_t burst,
ThrottlePolicy policy, std::
size_t value, std::
size_t period = 0);
235 virtual
Log& Throttle(const
Level& level,
double rate, std::
size_t burst);
274 virtual
Log& NoThrottle();
312 virtual
Log& FlushThrottle();
328 inline
Log& operator<<(
bool v) {
329 if (!WillWrite()) [[likely]]
return *
this;
334 if (!WillWrite()) [[likely]]
return *
this;
339 if (!WillWrite()) [[likely]]
return *
this;
344 if (!WillWrite()) [[likely]]
return *
this;
349 if (!WillWrite()) [[likely]]
return *
this;
354 if (!WillWrite()) [[likely]]
return *
this;
359 if (!WillWrite()) [[likely]]
return *
this;
364 if (!WillWrite()) [[likely]]
return *
this;
369 if (!WillWrite()) [[likely]]
return *
this;
374 if (!WillWrite()) [[likely]]
return *
this;
379 if (!WillWrite()) [[likely]]
return *
this;
384 if (!WillWrite()) [[likely]]
return *
this;
389 if (!WillWrite()) [[likely]]
return *
this;
394 if (!WillWrite()) [[likely]]
return *
this;
399 if (!WillWrite()) [[likely]]
return *
this;
409 if (!WillWrite()) [[likely]]
return *
this;
414 if (!WillWrite()) [[likely]]
return *
this;
424 if (!WillWrite()) [[likely]]
return *
this;
429 if (!WillWrite()) [[likely]]
return *
this;
440 if (!WillWrite()) [[likely]]
return *
this;
577 bool HasOpenOutputLine() const noexcept;
583 bool LineDecided() const noexcept;
589 bool LineAdmitted() const noexcept;
608 virtual
void Write(
bool v);
609 virtual
void Write(
char v);
610 virtual
void Write(
signed char v);
611 virtual
void Write(
unsigned char v);
612 virtual
void Write(
short v);
613 virtual
void Write(
unsigned short v);
614 virtual
void Write(
int v);
615 virtual
void Write(
unsigned int v);
616 virtual
void Write(
long v);
617 virtual
void Write(
unsigned long v);
618 virtual
void Write(
long long v);
619 virtual
void Write(
unsigned long long v);
620 virtual
void Write(
float v);
621 virtual
void Write(
double v);
622 virtual
void Write(
long double v);
623 virtual
void Write(std::string_view v);
624 virtual
void Write(const
char* v);
625 virtual
void Write(std::wstring_view v);
626 virtual
void Write(const
wchar_t* v);
631 virtual
void Write(std::span<const std::
byte> v);
632 virtual
void Write(const
Level& level);
633 virtual
void Write(std::ostream& (*manip)(std::ostream&));
634 virtual
void Write(
Log& (*manip)(
Log&) noexcept);
701 template <typename Ptr, typename T>
702 Ptr& operator<<(Ptr& logger, const T& value) noexcept
703 requires
StormByte::Type::DerivedFrom<typename std::remove_cvref_t<Ptr>::element_type,
Log> {
716 template <
typename Ptr>
718 requires StormByte::Type::DerivedFrom<typename std::remove_cvref_t<Ptr>::element_type,
Log> {
731 template <
typename Ptr>
732 Ptr&
operator<<(Ptr& logger, std::ostream& (*manip)(std::ostream&))
noexcept
733 requires StormByte::Type::DerivedFrom<typename std::remove_cvref_t<Ptr>::element_type,
Log> {
Public streaming facade for the StormByte logger.
Definition log.hxx:65
Log & operator<<(unsigned long v)
Definition log.hxx:373
Log & operator<<(std::span< const std::byte > v)
Stream raw bytes.
Definition log.hxx:439
Log & operator<<(double v)
Definition log.hxx:393
friend Log & nohumanreadable(Log &log) noexcept
Disable human-readable formatting (raw numbers).
Log & operator<<(PopComponentManip manip)
Pop one component segment from the current thread's stack.
Definition log.hxx:542
Log & operator<<(short v)
Definition log.hxx:348
Log & operator<<(float v)
Definition log.hxx:388
Log & operator<<(RedactManip m)
Apply redaction policy (full or keep-last-N).
Definition log.hxx:461
Log & operator<<(FormatManip manip)
Save the current format and activate a temporary format.
Definition log.hxx:506
Log & operator<<(signed char v)
Definition log.hxx:338
Log & operator<<(unsigned char v)
Definition log.hxx:343
Log & operator<<(NoHexManip m)
Disable hex dumps and restore default payload formatting.
Definition log.hxx:479
Log & operator<<(ComponentManip manip)
Push a component segment onto the current thread's stack.
Definition log.hxx:533
Log & operator<<(unsigned short v)
Definition log.hxx:353
Log & operator<<(std::wstring_view v)
Stream wide text.
Definition log.hxx:423
Log & operator<<(ResetComponentManip manip)
Clear the current thread's component stack.
Definition log.hxx:551
friend Log & noredact(Log &log) noexcept
Disable redaction until the next redact / redact(n) / redact_first(n).
Log & operator<<(const char *v)
Definition log.hxx:413
Log & operator<<(unsigned long long v)
Definition log.hxx:383
Log & operator<<(long long v)
Definition log.hxx:378
Log & operator<<(unsigned int v)
Definition log.hxx:363
Log & operator<<(long v)
Definition log.hxx:368
std::string m_scope_path
Sticky component path; empty = root facade.
Definition log.hxx:559
Log & operator<<(int v)
Definition log.hxx:358
Log(Log &&) noexcept=default
Move constructor.
Log & operator<<(ColorManip manip)
Apply a configured or explicit content color.
Definition log.hxx:488
Log & operator<<(PopFormatManip manip)
Restore the most recently saved format.
Definition log.hxx:515
Log & operator<<(GroupManip manip)
Set the producer group for the current line.
Definition log.hxx:524
Log & operator<<(std::ostream &(*manip)(std::ostream &))
Definition log.hxx:448
Log & operator<<(const wchar_t *v)
Definition log.hxx:428
Log & operator<<(Log &(*manip)(Log &) noexcept)
Definition log.hxx:452
Log & operator<<(std::string_view v)
Stream UTF-8 text.
Definition log.hxx:408
friend Log & humanreadable_bytes(Log &log) noexcept
Enable human-readable formatting for byte counts.
bool WillWrite() const noexcept
Whether the current line level will be written.
StormByte::Clonable< Log, std::shared_ptr< Log > >::PointerType PointerType
Smart pointer returned by Clone, Move and Scope.
Definition log.hxx:75
Log & operator<<(HexManip m)
Dump subsequent payloads as hex bytes until nohex.
Definition log.hxx:470
Log(std::ostream &out, const Level &level=Level::Info, const std::string &format="[%L] %T")
Construct a Log writing to out.
Log & operator<<(NoColorManip manip)
Disable color for subsequent content.
Definition log.hxx:497
Log & operator<<(char v)
Definition log.hxx:333
Log(const Log &)=default
Copy constructor.
friend Log & humanreadable_number(Log &log) noexcept
Enable human-readable formatting for numeric values.
std::shared_ptr< Implementation > m_impl
Shared backend (copies of Log share it)
Definition log.hxx:558
Log & operator<<(long double v)
Definition log.hxx:398
Log & operator<<(const Level &level)
Definition log.hxx:444
Logger module of the StormByte suite.
Ptr & operator<<(Ptr &logger, const T &value) noexcept
Stream a value into a smart pointer to Log or a derived logger.
Definition log.hxx:702
ThrottlePolicy
Count policy applied before the optional rate bucket.
Definition manipulators.hxx:40
Level
Severity levels used by the logger.
Definition typedefs.hxx:66
Color
ANSI foreground colors supported by the logger.
Definition typedefs.hxx:37
Temporarily selects a configured or explicit content color.
Definition manipulators.hxx:159
Selects the sticky component for the current thread.
Definition manipulators.hxx:88
Labels the current logging line with a producer group.
Definition manipulators.hxx:69
Dump subsequent payloads as hex bytes until nohex.
Definition manipulators.hxx:254
Disables color for subsequent content until changed.
Definition manipulators.hxx:181
Disable hex dumps and restore default payload formatting.
Definition manipulators.hxx:276
Pops one segment from the current thread's component stack.
Definition manipulators.hxx:121
Stateful redaction manipulator.
Definition manipulators.hxx:206
Clears the component associated with the current thread.
Definition manipulators.hxx:107
Immutable rule description used by Log::Throttle.
Definition manipulators.hxx:53
#define STORMBYTE_LOGGER_PUBLIC
Definition visibility.h:28