mirror of
https://github.com/gabime/spdlog.git
synced 2024-12-25 18:11:33 +08:00
Optional arguments for syslog_logger factory.
This commit is contained in:
parent
309fca8a72
commit
375b88c191
@ -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
|
|||||||
|
|
||||||
#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 @@
|
|||||||
|
|
||||||
#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.
|
||||||
*
|
*
|
||||||
|
@ -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
|
||||||
|
|
||||||
//
|
//
|
||||||
|
Loading…
Reference in New Issue
Block a user