Skip to main content

28 docs tagged with "spdlog"

View all tags

Async vs sync trade-offs

Async logging is not strictly better than sync โ€” it trades tail latency and complexity for

Backtrace and crash dump

The messages you want after a failure are almost always the debug-level ones you weren't writing to

Basic formatting

spdlog's format strings are fmt's format strings โ€” the same {} mini-language, with the same

Compile-time log level

A runtime level check is cheap, but it isn't free โ€” it's still a branch and, on the disabled path,

Console sinks

Console output is the default destination because it's the one that always exists โ€” no file

Creating loggers

There are two ways to make a logger: the factory helpers, which build a sink and register the logger

Custom formatters

When no built-in pattern flag carries the field you need โ€” a request id, a thread name, a tenant โ€”

Custom sinks

A custom sink is the supported way to send logs anywhere spdlog doesn't already reach โ€” an in-memory

Design philosophy

Three decisions explain almost every API in spdlog: formatting is delegated to fmt, sinks are the

File sinks

The simplest durable destination โ€” and the one whose failure modes (permissions, unbounded growth,

Flush policies

A log line that's still sitting in a buffer when the process dies never existed, as far as anyone

Log levels

Levels aren't one filter, they're two: a runtime one that lives per logger (and optionally per sink),

Logger lifecycle

Loggers are shared_ptr-owned. The registry holds one reference, you typically hold another (or

Multi-sink loggers

One logger, several destinations โ€” this is the standard shape for a real application: everything to

Overflow policies

The async queue is bounded, so at some point the producer (your application logging quickly) outruns

Overview of spdlog

spdlog is a very fast, header-only-by-default C++ logging library built on top of

Pattern flags

The pattern controls the line around your message โ€” timestamp, level, logger name, thread id โ€” and

Quick start

The default logger exists so that adding logging to a program is one include and one call. Everything

Rotating and daily sinks

Two different answers to "the log file cannot grow forever": rotate by size whenever the current file

Sink overview

The split of responsibility is deliberate: a logger decides whether to log at all, a sink decides

Syslog and platform sinks

When the platform already owns log collection โ€” syslog, the systemd journal, the Windows Event Log โ€”

The registry

The registry is a global nameโ†’logger map. It's what makes spdlog::get("db") work from any file in

What is spdlog?

For a long time, logging in C++ meant one of two things: hand-rolled iostream chains guarded by