diff --git a/include/spdlog/common.h b/include/spdlog/common.h index 1be17d0d..1712ee56 100644 --- a/include/spdlog/common.h +++ b/include/spdlog/common.h @@ -27,13 +27,42 @@ #include #include +#ifdef __linux__ + +#define SYSLOG_NAMES 1 +#include +#endif + namespace spdlog { + class formatter; + namespace sinks { + class sink; + +#ifdef __linux__ +namespace syslog +{ +namespace option +{ +typedef enum +{ + CONS = LOG_CONS, + NDELAY = LOG_NDELAY, + NOWAIT = LOG_NOWAIT, + ODELAY = LOG_ODELAY, + PERROR = LOG_PERROR, + PID = LOG_PID +} option_enum; } +} +#endif + +} + // Common types across the lib using log_clock = std::chrono::system_clock; diff --git a/include/spdlog/details/spdlog_impl.h b/include/spdlog/details/spdlog_impl.h index 0199a8df..c50cef89 100644 --- a/include/spdlog/details/spdlog_impl.h +++ b/include/spdlog/details/spdlog_impl.h @@ -87,11 +87,10 @@ inline std::shared_ptr spdlog::stderr_logger_st(const std::strin #ifdef __linux__ // Create syslog logger -inline std::shared_ptr spdlog::syslog_logger(const std::string& logger_name, const std::string& ident, int option , const std::string & facility) +inline std::shared_ptr spdlog::syslog_logger(const std::string& logger_name, const std::string& ident, int option, const std::string &facility) { return create(logger_name, ident, option, facility); } - #endif diff --git a/include/spdlog/sinks/syslog_sink.h b/include/spdlog/sinks/syslog_sink.h index 6a597d2d..2270f184 100644 --- a/include/spdlog/sinks/syslog_sink.h +++ b/include/spdlog/sinks/syslog_sink.h @@ -28,9 +28,7 @@ #include -#define SYSLOG_NAMES 1 -#include #include "./sink.h" #include "../common.h" #include "../details/log_msg.h" @@ -40,21 +38,6 @@ namespace spdlog { namespace sinks { -namespace syslog -{ -namespace option -{ -typedef enum -{ - CONS = LOG_CONS, - NDELAY = LOG_NDELAY, - NOWAIT = LOG_NOWAIT, - ODELAY = LOG_ODELAY, - PERROR = LOG_PERROR, - PID = LOG_PID -} option_enum; -} -} /** * Sink that write to syslog using the `syscall()` library call. * diff --git a/include/spdlog/spdlog.h b/include/spdlog/spdlog.h index 7e285efd..bb9b4980 100644 --- a/include/spdlog/spdlog.h +++ b/include/spdlog/spdlog.h @@ -96,7 +96,8 @@ std::shared_ptr stderr_logger_st(const std::string& logger_name); // Create a syslog logger // #ifdef __linux__ -std::shared_ptr syslog_logger(const std::string& logger_name, const std::string& ident, int option, const std::string &facility); + +std::shared_ptr syslog_logger(const std::string& logger_name, const std::string& ident = "", int option = static_cast(sinks::syslog::option::PID), const std::string &facility = "user"); #endif //