9#include "../log/detail/tagged_log_sink_base.hpp"
10#include "../log/sink.hpp"
34RELOCO_BEGIN_UNSAFE_BUFFER_USAGE
35inline int dlog_print(log_priority prio,
const char *tag,
const char *
fmt, ...) {
36 std::fprintf(stdout,
"[%d] %s: ",
static_cast<int>(prio), tag);
39 const int result = std::vfprintf(stdout,
fmt, args);
41 std::fprintf(stdout,
"\n");
44RELOCO_END_UNSAFE_BUFFER_USAGE
59 using write_fn_t = void (*)(
int priority, microfmt::string_view tag, microfmt::string_view message)
noexcept;
62 :
tag_base(tag), write_fn_(write_fn) {}
73 char scratch[TagCapacity];
74 const auto tag = this->
resolve_tag(msg.logger_name, scratch);
75 write_fn_(priority_for(msg.lvl), tag, msg.payload);
79 static void write_to_dlog(
int priority, microfmt::string_view tag, microfmt::string_view message)
noexcept {
80 ::dlog_print(
static_cast<::log_priority
>(priority), tag.data(),
"%.*s",
static_cast<int>(message.size()),
84 static int priority_for(
level lvl)
noexcept {
111tizen_dlog_sink(microfmt::string_view,
void (*)(
int, microfmt::string_view, microfmt::string_view)
noexcept)
117 static void log(value_ref<context_type> ctx,
const log_msg &msg)
noexcept { ctx->log_impl(msg); }
CRTP-free base providing fixed-capacity tag storage and truncating tag resolution,...
Definition tagged_log_sink_base.hpp:36
microfmt::string_view resolve_tag(microfmt::string_view logger_name, char(&scratch)[TagCapacity]) const &noexcept RELOCO_LIFETIMEBOUND
Resolves the tag to use for a record whose originating logger is named logger_name: that name (trunca...
Definition tagged_log_sink_base.hpp:65
Type-erased, two-word handle to a log sink backend, plus the severity threshold below which records a...
Definition sink.hpp:73
Adapter that writes structured records to Tizen DLOG.
Definition tizen_dlog_sink.hpp:55
void(*)(int priority, microfmt::string_view tag, microfmt::string_view message) noexcept write_fn_t
Definition tizen_dlog_sink.hpp:59
log_sink as_sink() &noexcept RELOCO_LIFETIMEBOUND
Definition tizen_dlog_sink.hpp:64
void log_impl(const log_msg &msg) noexcept
Definition tizen_dlog_sink.hpp:68
tizen_dlog_sink(microfmt::string_view tag="microfmt", write_fn_t write_fn=write_to_dlog) noexcept
Definition tizen_dlog_sink.hpp:61
Definition default_log_sink.template.hpp:51
tizen_dlog_sink() -> tizen_dlog_sink<>
level
Shared log severity levels in ascending order.
Definition log_msg.hpp:22
Structured log record forwarded by a logger to each sink.
Definition log_msg.hpp:69
static void log(value_ref< context_type > ctx, const log_msg &msg) noexcept
Definition tizen_dlog_sink.hpp:117
Static customization point describing a log sink backend.
Definition sink.hpp:46
Tag selecting tizen_dlog_sink<TagCapacity> as a log_sink backend.
Definition tizen_dlog_sink.hpp:52