27#include <sys/syscall.h>
35const char*
Labels[] = {
"NONE",
"CRIT",
"ERROR",
"WARN",
"METRIC",
"NOTICE",
"INFO",
"DEBUG"};
50class NullLogger
final :
public Logger {
52 size_t )
noexcept override
57class StdLogger
final :
public Logger {
59 size_t size)
noexcept override
72 size_t hlen{
strftime(head,
sizeof(head),
"%Y/%m/%d %H:%M:%S", &
tm)};
91class SysLogger
final :
public Logger {
93 size_t size)
noexcept override
120 syslog(
prio,
"%.*s",
static_cast<int>(
size),
static_cast<const char*
>(msg.get()));
194 write_all_messages();
197void AsyncLogger::write_all_messages()
207 write_all_messages();
208 std::this_thread::sleep_for(50
ms);
210 return (!tq_.empty() || !stop_);
219 size_t size)
noexcept
222 if (
void*
msg_ptr = msg.release();
223 !tq_.push(Task{.ts = ts, .level = level, .tid = tid, .msg =
msg_ptr, .size =
size})) {