Commit 375b88c1 authored by fooinha's avatar fooinha

Optional arguments for syslog_logger factory.

parent 309fca8a
......@@ -27,13 +27,42 @@
#include<initializer_list>
#include<chrono>
#ifdef __linux__
#define SYSLOG_NAMES 1
#include <syslog.h>
#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;
......
......@@ -87,11 +87,10 @@ inline std::shared_ptr<spdlog::logger> spdlog::stderr_logger_st(const std::strin
#ifdef __linux__
// 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);
}
#endif
......
......@@ -28,9 +28,7 @@
#include <string>
#define SYSLOG_NAMES 1
#include <syslog.h>
#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.
*
......
......@@ -96,7 +96,8 @@ std::shared_ptr<logger> stderr_logger_st(const std::string& logger_name);
// Create a syslog logger
//
#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
//
......
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