diff --git a/src/cpp-utils/logging/Logger.h b/src/cpp-utils/logging/Logger.h index 45e515c0..ceff576b 100644 --- a/src/cpp-utils/logging/Logger.h +++ b/src/cpp-utils/logging/Logger.h @@ -2,7 +2,10 @@ #ifndef MESSMER_CPPUTILS_LOGGING_LOGGER_H #define MESSMER_CPPUTILS_LOGGING_LOGGER_H +#if !defined(_MSC_VER) #define SPDLOG_ENABLE_SYSLOG +#endif + #include #include "../macros.h" diff --git a/src/cpp-utils/logging/logging.h b/src/cpp-utils/logging/logging.h index 065e70df..aed44db9 100644 --- a/src/cpp-utils/logging/logging.h +++ b/src/cpp-utils/logging/logging.h @@ -6,6 +6,10 @@ #include #include +#if defined(_MSC_VER) +#include +#endif + namespace cpputils { namespace logging { @@ -66,6 +70,14 @@ namespace cpputils { inline void LOG(DEBUG_TYPE, const char* fmt, const Args&... args) { logger()->debug(fmt, args...); } + + inline std::shared_ptr system_logger(const std::string& name) { +#if defined(_MSC_VER) + return spdlog::create(name); +#else + return spdlog::syslog_logger(name, name, LOG_PID); +#endif + } } } diff --git a/src/cryfs-cli/Cli.cpp b/src/cryfs-cli/Cli.cpp index 068fcd51..e6089b66 100644 --- a/src/cryfs-cli/Cli.cpp +++ b/src/cryfs-cli/Cli.cpp @@ -295,7 +295,7 @@ namespace cryfs { } else if (options.foreground()) { cpputils::logging::setLogger(spdlog::stderr_logger_mt("cryfs")); } else { - cpputils::logging::setLogger(spdlog::syslog_logger("cryfs", "cryfs", LOG_PID)); + cpputils::logging::setLogger(cpputils::logging::system_logger("cryfs")); } }