Fix logger for windows
This commit is contained in:
parent
70096de4e3
commit
79ba320714
@ -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 <spdlog/spdlog.h>
|
||||
#include "../macros.h"
|
||||
|
||||
|
@ -6,6 +6,10 @@
|
||||
#include <stdexcept>
|
||||
#include <spdlog/fmt/ostr.h>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#include <spdlog/sinks/msvc_sink.h>
|
||||
#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<spdlog::logger> system_logger(const std::string& name) {
|
||||
#if defined(_MSC_VER)
|
||||
return spdlog::create<spdlog::sinks::msvc_sink_mt>(name);
|
||||
#else
|
||||
return spdlog::syslog_logger(name, name, LOG_PID);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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"));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user