StripeKit 0.1.1
Stripe integration toolkit for C++
Loading...
Searching...
No Matches
stripekit::Logger Class Referenceabstract

Receives StripeKit's log entries. More...

#include <Logging.h>

Inheritance diagram for stripekit::Logger:
[legend]

Public Member Functions

virtual ~Logger ()=default
 Destroys the logger instance.
virtual bool should_log (LogLevel level) const =0
 Reports whether entries at this level are wanted.
virtual void log (LogLevel level, std::string_view message, const LogContext &context=LogContext{})=0
 Writes one entry.

Detailed Description

Receives StripeKit's log entries.

Implement this to route StripeKit's diagnostics into the application's own log. Adapters usually provide one already, such as stripekit::drogon::LogBridge.

Entries may be written from any thread, so implementations must be thread-safe. They must not throw, and must never write the API key or the webhook signing secret; redact_sensitive_text() helps with the latter.

See also
Writing an Adapter

Definition at line 74 of file Logging.h.

Constructor & Destructor Documentation

◆ ~Logger()

virtual stripekit::Logger::~Logger ( )
virtualdefault

Destroys the logger instance.

Member Function Documentation

◆ should_log()

virtual bool stripekit::Logger::should_log ( LogLevel level) const
pure virtual

Reports whether entries at this level are wanted.

StripeKit checks this before building a message, so answering honestly avoids formatting work for entries that would be thrown away.

Parameters
levelSeverity being considered.
Returns
True when an entry at that level would be written.

Implemented in stripekit::ConsoleLogger, stripekit::drogon::LogBridge, and stripekit::NullLogger.

◆ log()

virtual void stripekit::Logger::log ( LogLevel level,
std::string_view message,
const LogContext & context = LogContext{} )
pure virtual

Writes one entry.

Parameters
levelSeverity of the entry.
messageThe text to record.
contextIdentifiers to attach. Fields that do not apply are empty.

Implemented in stripekit::ConsoleLogger, stripekit::drogon::LogBridge, and stripekit::NullLogger.


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