31 #ifndef WEBSOCKETPP_LOGGER_SYSLOG_HPP 32 #define WEBSOCKETPP_LOGGER_SYSLOG_HPP 36 #include <websocketpp/logger/basic.hpp> 38 #include <websocketpp/common/cpp11.hpp> 39 #include <websocketpp/logger/levels.hpp> 45 template <
typename concurrency,
typename names>
48 typedef basic<concurrency, names> base;
54 syslog<concurrency,names>(channel_type_hint::value hint =
55 channel_type_hint::access)
56 : basic<concurrency,names>(hint), m_channel_type_hint(hint) {}
63 syslog<concurrency,names>(level channels, channel_type_hint::value hint =
64 channel_type_hint::access)
65 : basic<concurrency,names>(channels, hint), m_channel_type_hint(hint) {}
72 void write(level channel, std::string
const & msg) {
73 write(channel, msg.c_str());
81 void write(level channel,
char const * msg) {
82 scoped_lock_type lock(base::m_lock);
83 if (!
this->dynamic_test(channel)) {
return; }
84 ::syslog(syslog_priority(channel),
"[%s] %s",
85 names::channel_name(channel), msg);
92 static int const default_level = LOG_INFO;
99 int syslog_priority(level channel)
const {
100 if (m_channel_type_hint == channel_type_hint::access) {
101 return syslog_priority_access(channel);
103 return syslog_priority_error(channel);
112 int syslog_priority_error(level channel)
const {
116 case elevel::library:
127 return default_level;
136 _WEBSOCKETPP_CONSTEXPR_TOKEN_
int syslog_priority_access(level)
const {
137 return default_level;
140 channel_type_hint::value m_channel_type_hint;
lib::weak_ptr< void > connection_hdl
A handle to uniquely identify a connection.
void write(level channel, char const *msg)
Write a cstring message to the given channel.
Basic logger that outputs to syslog.
void write(level channel, std::string const &msg)
Write a string message to the given channel.