Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
spdlog::sinks::syslog_sink< Mutex > Class Template Reference

#include <syslog_sink.h>

Inheritance diagram for spdlog::sinks::syslog_sink< Mutex >:
spdlog::sinks::base_sink< Mutex > spdlog::sinks::sink

Public Member Functions

 syslog_sink (std::string ident="", int syslog_option=0, int syslog_facility=LOG_USER)
 
 ~syslog_sink () override
 
 syslog_sink (const syslog_sink &)=delete
 
syslog_sinkoperator= (const syslog_sink &)=delete
 
- Public Member Functions inherited from spdlog::sinks::base_sink< Mutex >
 base_sink ()=default
 
 base_sink (const base_sink &)=delete
 
base_sinkoperator= (const base_sink &)=delete
 
void log (const details::log_msg &msg) final
 
void flush () final
 
void set_pattern (const std::string &pattern) final
 
void set_formatter (std::unique_ptr< spdlog::formatter > sink_formatter) final
 
- Public Member Functions inherited from spdlog::sinks::sink
 sink ()
 
 sink (std::unique_ptr< spdlog::pattern_formatter > formatter)
 
virtual ~sink ()=default
 
bool should_log (level::level_enum msg_level) const
 
void set_level (level::level_enum log_level)
 
level::level_enum level () const
 

Protected Member Functions

void sink_it_ (const details::log_msg &msg) override
 
void flush_ () override
 
- Protected Member Functions inherited from spdlog::sinks::base_sink< Mutex >
virtual void set_pattern_ (const std::string &pattern)
 
virtual void set_formatter_ (std::unique_ptr< spdlog::formatter > sink_formatter)
 

Private Member Functions

int syslog_prio_from_level (const details::log_msg &msg) const
 

Private Attributes

std::array< int, 7 > priorities_
 
const std::string ident_
 

Additional Inherited Members

- Protected Attributes inherited from spdlog::sinks::base_sink< Mutex >
Mutex mutex_
 
- Protected Attributes inherited from spdlog::sinks::sink
level_t level_
 
std::unique_ptr< spdlog::formatterformatter_
 

Detailed Description

template<typename Mutex>
class spdlog::sinks::syslog_sink< Mutex >

Sink that write to syslog using the syscall() library call.

Locking is not needed, as syslog() itself is thread-safe.

Definition at line 26 of file syslog_sink.h.

Constructor & Destructor Documentation

template<typename Mutex >
spdlog::sinks::syslog_sink< Mutex >::syslog_sink ( std::string  ident = "",
int  syslog_option = 0,
int  syslog_facility = LOG_USER 
)
inlineexplicit

Definition at line 30 of file syslog_sink.h.

31  : ident_(std::move(ident))
32  {
33  priorities_[static_cast<size_t>(level::trace)] = LOG_DEBUG;
34  priorities_[static_cast<size_t>(level::debug)] = LOG_DEBUG;
35  priorities_[static_cast<size_t>(level::info)] = LOG_INFO;
36  priorities_[static_cast<size_t>(level::warn)] = LOG_WARNING;
37  priorities_[static_cast<size_t>(level::err)] = LOG_ERR;
38  priorities_[static_cast<size_t>(level::critical)] = LOG_CRIT;
39  priorities_[static_cast<size_t>(level::off)] = LOG_INFO;
40 
41  // set ident to be program name if empty
42  ::openlog(ident_.empty() ? nullptr : ident_.c_str(), syslog_option, syslog_facility);
43  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:148
std::array< int, 7 > priorities_
Definition: syslog_sink.h:62
#define LOG_CRIT(stream)
Definition: Messenger.h:123
def move(depos, offset)
Definition: depos.py:107
const std::string ident_
Definition: syslog_sink.h:65
#define LOG_INFO(stream)
Definition: Messenger.h:143
template<typename Mutex >
spdlog::sinks::syslog_sink< Mutex >::~syslog_sink ( )
inlineoverride

Definition at line 45 of file syslog_sink.h.

46  {
47  ::closelog();
48  }
template<typename Mutex >
spdlog::sinks::syslog_sink< Mutex >::syslog_sink ( const syslog_sink< Mutex > &  )
delete

Member Function Documentation

template<typename Mutex >
void spdlog::sinks::syslog_sink< Mutex >::flush_ ( )
inlineoverrideprotectedvirtual

Implements spdlog::sinks::base_sink< Mutex >.

Definition at line 59 of file syslog_sink.h.

59 {}
template<typename Mutex >
syslog_sink& spdlog::sinks::syslog_sink< Mutex >::operator= ( const syslog_sink< Mutex > &  )
delete
template<typename Mutex >
void spdlog::sinks::syslog_sink< Mutex >::sink_it_ ( const details::log_msg msg)
inlineoverrideprotectedvirtual

Implements spdlog::sinks::base_sink< Mutex >.

Definition at line 54 of file syslog_sink.h.

55  {
56  ::syslog(syslog_prio_from_level(msg), "%s", fmt::to_string(msg.payload).c_str());
57  }
void msg(const char *fmt,...)
Definition: message.cpp:107
int syslog_prio_from_level(const details::log_msg &msg) const
Definition: syslog_sink.h:70
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34
template<typename Mutex >
int spdlog::sinks::syslog_sink< Mutex >::syslog_prio_from_level ( const details::log_msg msg) const
inlineprivate

Definition at line 70 of file syslog_sink.h.

71  {
72  return priorities_[static_cast<size_t>(msg.level)];
73  }
void msg(const char *fmt,...)
Definition: message.cpp:107
std::array< int, 7 > priorities_
Definition: syslog_sink.h:62

Member Data Documentation

template<typename Mutex >
const std::string spdlog::sinks::syslog_sink< Mutex >::ident_
private

Definition at line 65 of file syslog_sink.h.

template<typename Mutex >
std::array<int, 7> spdlog::sinks::syslog_sink< Mutex >::priorities_
private

Definition at line 62 of file syslog_sink.h.


The documentation for this class was generated from the following file: