Move syslog support tests to one place.

This commit is contained in:
Nazım Can Bedir 2016-08-22 16:39:13 +03:00
parent e556daebc3
commit 2678c37b56
5 changed files with 12 additions and 5 deletions

View File

@ -108,7 +108,7 @@ void async_example()
//syslog example (linux/osx/freebsd) //syslog example (linux/osx/freebsd)
void syslog_example() void syslog_example()
{ {
#if defined (__linux__) || defined(__APPLE__) || defined(__FreeBSD__) #ifdef SPDLOG_ENABLE_SYSLOG
std::string ident = "spdlog-example"; std::string ident = "spdlog-example";
auto syslog_logger = spd::syslog_logger("syslog", ident, LOG_PID); auto syslog_logger = spd::syslog_logger("syslog", ident, LOG_PID);
syslog_logger->warn("This is warning that will end up in syslog."); syslog_logger->warn("This is warning that will end up in syslog.");

View File

@ -37,6 +37,12 @@
#define DEPRECATED #define DEPRECATED
#endif #endif
#ifndef SPDLOG_ENABLE_SYSLOG
#if defined (__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
#define SPDLOG_ENABLE_SYSLOG
#endif
#endif
#include <spdlog/fmt/fmt.h> #include <spdlog/fmt/fmt.h>

View File

@ -96,7 +96,7 @@ inline std::shared_ptr<spdlog::logger> spdlog::stderr_logger_st(const std::strin
return create_console_logger(logger_name, sinks::stderr_sink_st::instance(), color); return create_console_logger(logger_name, sinks::stderr_sink_st::instance(), color);
} }
#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) #ifdef SPDLOG_ENABLE_SYSLOG
// Create syslog logger // Create syslog logger
inline std::shared_ptr<spdlog::logger> spdlog::syslog_logger(const std::string& logger_name, const std::string& syslog_ident, int syslog_option) inline std::shared_ptr<spdlog::logger> spdlog::syslog_logger(const std::string& logger_name, const std::string& syslog_ident, int syslog_option)
{ {

View File

@ -5,10 +5,11 @@
#pragma once #pragma once
#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) #include <spdlog/common.h>
#ifdef SPDLOG_ENABLE_SYSLOG
#include <spdlog/sinks/sink.h> #include <spdlog/sinks/sink.h>
#include <spdlog/common.h>
#include <spdlog/details/log_msg.h> #include <spdlog/details/log_msg.h>
#include <array> #include <array>

View File

@ -98,7 +98,7 @@ std::shared_ptr<logger> stderr_logger_st(const std::string& logger_name, bool co
// //
// Create and register a syslog logger // Create and register a syslog logger
// //
#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) #ifdef SPDLOG_ENABLE_SYSLOG
std::shared_ptr<logger> syslog_logger(const std::string& logger_name, const std::string& ident = "", int syslog_option = 0); std::shared_ptr<logger> syslog_logger(const std::string& logger_name, const std::string& ident = "", int syslog_option = 0);
#endif #endif