mirror of
https://github.com/gabime/spdlog.git
synced 2025-11-16 09:28:56 +08:00
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:
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user