Optional arguments for syslog_logger factory.

This commit is contained in:
fooinha 2014-12-18 15:47:43 +00:00
parent 309fca8a72
commit 375b88c191
4 changed files with 32 additions and 20 deletions

View File

@ -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;

View File

@ -91,7 +91,6 @@ inline std::shared_ptr<spdlog::logger> spdlog::syslog_logger(const std::string&
{ {
return create<spdlog::sinks::syslog_sink>(logger_name, ident, option, facility); return create<spdlog::sinks::syslog_sink>(logger_name, ident, option, facility);
} }
#endif #endif

View File

@ -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
{ {
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.
* *

View File

@ -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
// //