From 2678c37b56ab680cec2109805e28d2eeec743e0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Naz=C4=B1m=20Can=20Bedir?= Date: Mon, 22 Aug 2016 16:39:13 +0300 Subject: [PATCH] Move syslog support tests to one place. --- example/example.cpp | 2 +- include/spdlog/common.h | 6 ++++++ include/spdlog/details/spdlog_impl.h | 2 +- include/spdlog/sinks/syslog_sink.h | 5 +++-- include/spdlog/spdlog.h | 2 +- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/example/example.cpp b/example/example.cpp index 99c18993..692f8e9a 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -108,7 +108,7 @@ void async_example() //syslog example (linux/osx/freebsd) void syslog_example() { -#if defined (__linux__) || defined(__APPLE__) || defined(__FreeBSD__) +#ifdef SPDLOG_ENABLE_SYSLOG std::string ident = "spdlog-example"; auto syslog_logger = spd::syslog_logger("syslog", ident, LOG_PID); syslog_logger->warn("This is warning that will end up in syslog."); diff --git a/include/spdlog/common.h b/include/spdlog/common.h index 490deec7..1accd1dd 100644 --- a/include/spdlog/common.h +++ b/include/spdlog/common.h @@ -37,6 +37,12 @@ #define DEPRECATED #endif +#ifndef SPDLOG_ENABLE_SYSLOG +#if defined (__linux__) || defined(__APPLE__) || defined(__FreeBSD__) +#define SPDLOG_ENABLE_SYSLOG +#endif +#endif + #include diff --git a/include/spdlog/details/spdlog_impl.h b/include/spdlog/details/spdlog_impl.h index b6ba5ad0..4ef085b6 100644 --- a/include/spdlog/details/spdlog_impl.h +++ b/include/spdlog/details/spdlog_impl.h @@ -96,7 +96,7 @@ inline std::shared_ptr spdlog::stderr_logger_st(const std::strin 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 inline std::shared_ptr spdlog::syslog_logger(const std::string& logger_name, const std::string& syslog_ident, int syslog_option) { diff --git a/include/spdlog/sinks/syslog_sink.h b/include/spdlog/sinks/syslog_sink.h index 1c571ef7..4c5b6876 100644 --- a/include/spdlog/sinks/syslog_sink.h +++ b/include/spdlog/sinks/syslog_sink.h @@ -5,10 +5,11 @@ #pragma once -#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) +#include + +#ifdef SPDLOG_ENABLE_SYSLOG #include -#include #include #include diff --git a/include/spdlog/spdlog.h b/include/spdlog/spdlog.h index 8a0ba08f..ff1b6022 100644 --- a/include/spdlog/spdlog.h +++ b/include/spdlog/spdlog.h @@ -98,7 +98,7 @@ std::shared_ptr stderr_logger_st(const std::string& logger_name, bool co // // Create and register a syslog logger // -#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) +#ifdef SPDLOG_ENABLE_SYSLOG std::shared_ptr syslog_logger(const std::string& logger_name, const std::string& ident = "", int syslog_option = 0); #endif