10#ifdef SPDLOG_ENABLE_SYSLOG
13#include "../details/log_msg.h"
25
26
27
28
29class syslog_sink :
public sink
33 syslog_sink(
const std::string& ident =
"",
int syslog_option=0,
int syslog_facility=LOG_USER):
36 _priorities[
static_cast<
int>(level::trace)] = LOG_DEBUG;
37 _priorities[
static_cast<
int>(level::debug)] = LOG_DEBUG;
38 _priorities[
static_cast<
int>(level::info)] = LOG_INFO;
39 _priorities[
static_cast<
int>(level::warn)] = LOG_WARNING;
40 _priorities[
static_cast<
int>(level::err)] = LOG_ERR;
41 _priorities[
static_cast<
int>(level::critical)] = LOG_CRIT;
42 _priorities[
static_cast<
int>(level::off)] = LOG_INFO;
45 ::openlog(_ident.empty()?
nullptr:_ident.c_str(), syslog_option, syslog_facility);
52 syslog_sink(
const syslog_sink&) =
delete;
53 syslog_sink& operator=(
const syslog_sink&) =
delete;
55 void log(
const details::log_msg &msg) override
57 ::syslog(syslog_prio_from_level(msg),
"%s", msg.raw.str().c_str());
66 std::array<
int, 7> _priorities;
68 const std::string _ident;
73 int syslog_prio_from_level(
const details::log_msg &msg)
const
75 return _priorities[
static_cast<
int>(msg.level)];