Optional arguments for syslog_logger factory.
This commit is contained in:
parent
309fca8a72
commit
375b88c191
@ -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
|
||||
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user