18#include <unordered_map>
52 using creator_fn = std::function<std::unique_ptr<log_formatter_interface>()>;
66 return std::make_unique<timestamp_formatter>(opts);
77 return std::make_unique<json_formatter>(opts);
89 return std::make_unique<logfmt_formatter>(opts);
103 return std::make_unique<template_formatter>(template_pattern, opts);
119 return std::make_unique<timestamp_formatter>(opts);
128 static std::unique_ptr<log_formatter_interface>
create(
203 registry()[name] = std::move(creator);
211 static std::unique_ptr<log_formatter_interface>
create(
const std::string& name) {
229 static std::unordered_map<std::string, creator_fn>&
registry() {
230 static std::unordered_map<std::string, creator_fn> instance;
format_type
Pre-defined format types.
@ logfmt
Logfmt key=value format.
@ json
JSON structured format.
@ templated
Template-based custom format.
@ compact
Compact single-line format.
@ plain
Plain text with timestamps.