microfmt
Zero-allocation C++ formatting for constrained environments
Loading...
Searching...
No Matches
Classes | Namespaces | Concepts
extended_sink.hpp File Reference

"Advanced" log sinks that see extended_log_msg metadata and can report being full, plus a fixed-capacity fan-out sink that applies back-pressure across several of them. More...

#include "../microfmt.hpp"
#include "extended_msg.hpp"
#include "sink.hpp"
#include "sync.hpp"
#include <atomic>
#include <concepts>
#include <cstddef>
#include <cstdint>
#include <type_traits>
Include dependency graph for extended_sink.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  microfmt::log::extended_log_sink
 Type-erased handle to an advanced log sink backend, with a severity threshold. Same two-word-plus-vtable shape as log_sink. More...
 
struct  microfmt::log::extended_log_sink::vtable
 
struct  microfmt::log::fanout_log_sink_tag< MaxSinks, Channel >
 
class  microfmt::log::fanout_log_sink< MaxSinks, Channel >
 Fixed-capacity sink that forwards each record to up to MaxSinks advanced sinks ("pins"), applies back-pressure when one is full, and keeps thread-context writers in FIFO order. Nothing here busy-waits. More...
 
struct  microfmt::log::extended_log_sink_traits< fanout_log_sink_tag< MaxSinks, Channel > >
 

Namespaces

namespace  microfmt
 
namespace  microfmt::log
 
namespace  microfmt::log::detail
 Fixed-capacity logger that formats records before dispatching to sinks.
 

Concepts

concept  microfmt::log::detail::has_extended_full
 
concept  microfmt::log::detail::has_extended_flush
 

Detailed Description

"Advanced" log sinks that see extended_log_msg metadata and can report being full, plus a fixed-capacity fan-out sink that applies back-pressure across several of them.

These sinks intentionally do not mirror the legacy log_sink API: their log takes an extended_log_msg and they may expose full.

// A backend: tag + traits. `context_type` holds the state.
struct my_ring_tag {};
struct my_ring { / * ring buffer, its own lock, ... * / };
template <> struct microfmt::log::extended_log_sink_traits<my_ring_tag> {
using context_type = my_ring;
// Mandatory. msg.meta.can_wait() == false (IRQ): overwrite the oldest
// data when full. == true (thread): the fan-out already waited for
// space, so just append, and drop only if that raced.
static void log(microfmt::value_ref<my_ring> ctx, const microfmt::log::extended_log_msg &msg) noexcept;
// Optional. true when `msg` would not fit without waiting/overwriting.
static bool full(microfmt::value_ref<my_ring> ctx, const microfmt::log::extended_log_msg &msg) noexcept;
// Optional.
static void flush(microfmt::value_ref<my_ring> ctx) noexcept;
};
log_msg plus log_meta. Derives from the original record, so it converts to const log_msg & anywhere t...
Definition extended_msg.hpp:62
Customization point for extended_log_sink backends.
Definition extended_sink.hpp:56