Commit 375b88c1 authored by fooinha's avatar fooinha

Optional arguments for syslog_logger factory.

parent 309fca8a
...@@ -27,13 +27,42 @@ ...@@ -27,13 +27,42 @@
#include<initializer_list> #include<initializer_list>
#include<chrono> #include<chrono>
#ifdef __linux__
#define SYSLOG_NAMES 1
#include <syslog.h>
#endif
namespace spdlog namespace spdlog
{ {
class formatter; class formatter;
namespace sinks namespace sinks
{ {
class sink; 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 // Common types across the lib
using log_clock = std::chrono::system_clock; using log_clock = std::chrono::system_clock;
......
...@@ -87,11 +87,10 @@ inline std::shared_ptr<spdlog::logger> spdlog::stderr_logger_st(const std::strin ...@@ -87,11 +87,10 @@ inline std::shared_ptr<spdlog::logger> spdlog::stderr_logger_st(const std::strin
#ifdef __linux__ #ifdef __linux__
// Create syslog logger // Create syslog logger
inline std::shared_ptr<spdlog::logger> spdlog::syslog_logger(const std::string& logger_name, const std::string& ident, int option , const std::string & facility) inline std::shared_ptr<spdlog::logger> spdlog::syslog_logger(const std::string& logger_name, const std::string& ident, int option, const std::string &facility)
{ {
return create<spdlog::sinks::syslog_sink>(logger_name, ident, option, facility); return create<spdlog::sinks::syslog_sink>(logger_name, ident, option, facility);
} }
#endif #endif
......
...@@ -28,9 +28,7 @@ ...@@ -28,9 +28,7 @@
#include <string> #include <string>
#define SYSLOG_NAMES 1
#include <syslog.h>
#include "./sink.h" #include "./sink.h"
#include "../common.h" #include "../common.h"
#include "../details/log_msg.h" #include "../details/log_msg.h"
...@@ -40,21 +38,6 @@ namespace spdlog ...@@ -40,21 +38,6 @@ namespace spdlog
{ {
namespace sinks 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. * Sink that write to syslog using the `syscall()` library call.
* *
......
...@@ -96,7 +96,8 @@ std::shared_ptr<logger> stderr_logger_st(const std::string& logger_name); ...@@ -96,7 +96,8 @@ std::shared_ptr<logger> stderr_logger_st(const std::string& logger_name);
// Create a syslog logger // Create a syslog logger
// //
#ifdef __linux__ #ifdef __linux__
std::shared_ptr<logger> syslog_logger(const std::string& logger_name, const std::string& ident, int option, const std::string &facility);
std::shared_ptr<logger> syslog_logger(const std::string& logger_name, const std::string& ident = "", int option = static_cast<int>(sinks::syslog::option::PID), const std::string &facility = "user");
#endif #endif
// //
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment