23#include <StormByte/thread_lock.hxx>
55 ThreadedLog(std::ostream& out,
const Level& level = Level::Info,
const std::string& format =
"[%L] %T");
124 Log& Format(const std::
string& format) override;
130 const std::
string& Format() const override;
138 Log& Format(const std::
string& component, const std::
string& format) override;
145 const std::
string& Format(const std::
string& component) const override;
167 Log& Throttle(
double rate, std::
size_t burst) override;
178 Log& Throttle(
double rate, std::
size_t burst,
ThrottlePolicy policy, std::
size_t value, std::
size_t period = 0) override;
187 Log& Throttle(const
Level& level,
double rate, std::
size_t burst) override;
225 Log& NoThrottle() override;
261 Log& FlushThrottle() override;
275 inline
Log& operator<<(
bool v) {
276 if (!WillWrite()) [[likely]]
return *
this;
281 if (!WillWrite()) [[likely]]
return *
this;
286 if (!WillWrite()) [[likely]]
return *
this;
291 if (!WillWrite()) [[likely]]
return *
this;
296 if (!WillWrite()) [[likely]]
return *
this;
301 if (!WillWrite()) [[likely]]
return *
this;
306 if (!WillWrite()) [[likely]]
return *
this;
311 if (!WillWrite()) [[likely]]
return *
this;
316 if (!WillWrite()) [[likely]]
return *
this;
321 if (!WillWrite()) [[likely]]
return *
this;
326 if (!WillWrite()) [[likely]]
return *
this;
331 if (!WillWrite()) [[likely]]
return *
this;
336 if (!WillWrite()) [[likely]]
return *
this;
341 if (!WillWrite()) [[likely]]
return *
this;
346 if (!WillWrite()) [[likely]]
return *
this;
356 if (!WillWrite()) [[likely]]
return *
this;
361 if (!WillWrite()) [[likely]]
return *
this;
371 if (!WillWrite()) [[likely]]
return *
this;
376 if (!WillWrite()) [[likely]]
return *
this;
386 if (!WillWrite()) [[likely]]
return *
this;
518 std::shared_ptr<ThreadLock> m_lock;
525 void Write(
bool v)
override;
526 void Write(
char v)
override;
527 void Write(
signed char v)
override;
528 void Write(
unsigned char v)
override;
529 void Write(
short v)
override;
530 void Write(
unsigned short v)
override;
531 void Write(
int v)
override;
532 void Write(
unsigned int v)
override;
533 void Write(
long v)
override;
534 void Write(
unsigned long v)
override;
535 void Write(
long long v)
override;
536 void Write(
unsigned long long v)
override;
537 void Write(
float v)
override;
538 void Write(
double v)
override;
539 void Write(
long double v)
override;
540 void Write(std::string_view v)
override;
541 void Write(
const char* v)
override;
542 void Write(std::wstring_view v)
override;
543 void Write(
const wchar_t* v)
override;
548 void Write(std::span<const std::byte> v)
override;
549 void Write(
const Level& level)
override;
550 void Write(std::ostream& (*manip)(std::ostream&))
override;
551 void Write(
Log& (*manip)(
Log&)
noexcept)
override;
Public streaming facade for the StormByte logger.
Definition log.hxx:65
StormByte::Clonable< Log, std::shared_ptr< Log > >::PointerType PointerType
Smart pointer returned by Clone, Move and Scope.
Definition log.hxx:75
Thread-safe logging facade.
Definition threaded_log.hxx:47
Log & operator<<(PopFormatManip manip)
Restore a saved format under the line lock.
Definition threaded_log.hxx:461
PointerType Move() override
Move this facade into a shared_ptr.
Log & operator<<(const Level &level)
Definition threaded_log.hxx:390
Log & operator<<(ColorManip manip)
Apply a configured or explicit content color.
Definition threaded_log.hxx:434
Log & operator<<(float v)
Definition threaded_log.hxx:335
Log & operator<<(long v)
Definition threaded_log.hxx:315
Log & operator<<(NoColorManip manip)
Disable color for subsequent content.
Definition threaded_log.hxx:443
Log & operator<<(const char *v)
Definition threaded_log.hxx:360
Log & operator<<(ComponentManip manip)
Push a component segment onto the current thread's stack.
Definition threaded_log.hxx:479
Log & operator<<(unsigned long long v)
Definition threaded_log.hxx:330
Log & operator<<(ResetComponentManip manip)
Clear the current thread's component stack.
Definition threaded_log.hxx:497
Log & operator<<(std::wstring_view v)
Stream wide text.
Definition threaded_log.hxx:370
Log & operator<<(std::ostream &(*manip)(std::ostream &))
Definition threaded_log.hxx:394
Log & operator<<(long long v)
Definition threaded_log.hxx:325
ThreadedLog(std::ostream &out, const Level &level=Level::Info, const std::string &format="[%L] %T")
Construct a ThreadedLog writing to out.
Log & operator<<(double v)
Definition threaded_log.hxx:340
Log & operator<<(std::string_view v)
Stream UTF-8 text.
Definition threaded_log.hxx:355
ThreadedLog(const ThreadedLog &)=default
Copy constructor.
Log & operator<<(int v)
Definition threaded_log.hxx:305
PointerType Clone() const override
Deep-copy this facade into a shared_ptr.
ThreadedLog(ThreadedLog &&) noexcept=default
Move constructor.
Log & operator<<(NoHexManip m)
Disable hex dumps and restore default payload formatting.
Definition threaded_log.hxx:425
Log & operator<<(FormatManip manip)
Save and activate a temporary format under the line lock.
Definition threaded_log.hxx:452
Log & operator<<(PopComponentManip manip)
Pop one component segment from the current thread's stack.
Definition threaded_log.hxx:488
Log & operator<<(unsigned int v)
Definition threaded_log.hxx:310
Log & operator<<(short v)
Definition threaded_log.hxx:295
Log & operator<<(unsigned long v)
Definition threaded_log.hxx:320
Log & operator<<(const wchar_t *v)
Definition threaded_log.hxx:375
Log & operator<<(char v)
Definition threaded_log.hxx:280
Log & operator<<(Log &(*manip)(Log &) noexcept)
Definition threaded_log.hxx:398
Log & operator<<(unsigned short v)
Definition threaded_log.hxx:300
Log & operator<<(RedactManip m)
Apply redaction policy.
Definition threaded_log.hxx:407
Log & operator<<(std::span< const std::byte > v)
Stream raw bytes.
Definition threaded_log.hxx:385
Log & operator<<(HexManip m)
Dump subsequent payloads as hex bytes until nohex.
Definition threaded_log.hxx:416
Log & operator<<(GroupManip manip)
Set the producer group for the current line under the line lock.
Definition threaded_log.hxx:470
Log & operator<<(long double v)
Definition threaded_log.hxx:345
Log & operator<<(unsigned char v)
Definition threaded_log.hxx:290
Log & operator<<(signed char v)
Definition threaded_log.hxx:285
Logger module of the StormByte suite.
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