Add a syslog() based sink for Linux.

This commit introduce a new sink: syslog_sink.
This sink is Linux only, and will write log entries to the system
logger, using the syslog() library call.

It is instanciable using spdlog::syslog_logger(name). Note that
the suffix _st or _mt is not present, as syslog() is thread-safe.

I also applied @gabime reviews and added license header.
This commit is contained in:
Arnaud Kapp
2014-11-11 00:12:47 +01:00
parent 3569a76b4c
commit 67eef26c26
6 changed files with 121 additions and 12 deletions

View File

@@ -126,7 +126,7 @@ public:
swap(first._dev, second._dev);
}
std::string str()
std::string str() const
{
auto& buffer = _dev.buf();
const char*data = buffer.data();

View File

@@ -30,6 +30,7 @@
#include "registry.h"
#include "../sinks/file_sinks.h"
#include "../sinks/stdout_sinks.h"
#include "../sinks/syslog_sink.h"
inline std::shared_ptr<spdlog::logger> spdlog::get(const std::string& name)
{
@@ -81,6 +82,13 @@ inline std::shared_ptr<spdlog::logger> spdlog::stderr_logger_st(const std::strin
}
// Create syslog logger
inline std::shared_ptr<spdlog::logger> spdlog::syslog_logger(const std::string& logger_name)
{
return create<spdlog::sinks::syslog_sink>(logger_name);
}
inline std::shared_ptr<spdlog::logger> spdlog::create(const std::string& logger_name, spdlog::sinks_init_list sinks)
{
return details::registry::instance().create(logger_name, sinks);