|
|
|
@ -14,7 +14,9 @@
|
|
|
|
|
#include <spdlog/sinks/stdout_sinks.h>
|
|
|
|
|
#include <spdlog/sinks/syslog_sink.h>
|
|
|
|
|
#include <spdlog/sinks/ansicolor_sink.h>
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
#include <spdlog/sinks/wincolor_sink.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include <chrono>
|
|
|
|
|
#include <functional>
|
|
|
|
@ -59,11 +61,22 @@ inline std::shared_ptr<spdlog::logger> spdlog::daily_logger_st(const std::string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create stdout/stderr loggers (with optinal color support)
|
|
|
|
|
inline std::shared_ptr<spdlog::logger> create_console_logger(const std::string& logger_name, spdlog::sink_ptr sink, bool color)
|
|
|
|
|
inline std::shared_ptr<spdlog::logger> create_console_logger_st(const std::string& logger_name, spdlog::sink_ptr sink, bool color)
|
|
|
|
|
{
|
|
|
|
|
if (color) //use color wrapper sink
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
sink = std::make_shared<spdlog::sinks::wincolor_sink_st>(sink);
|
|
|
|
|
#else
|
|
|
|
|
sink = std::make_shared<spdlog::sinks::ansicolor_sink>(sink);
|
|
|
|
|
#endif
|
|
|
|
|
return spdlog::details::registry::instance().create(logger_name, sink);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline std::shared_ptr<spdlog::logger> create_console_logger_mt(const std::string& logger_name, spdlog::sink_ptr sink, bool color)
|
|
|
|
|
{
|
|
|
|
|
if (color) //use color wrapper sink
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
sink = std::make_shared<spdlog::sinks::wincolor_sink>(sink);
|
|
|
|
|
sink = std::make_shared<spdlog::sinks::wincolor_sink_mt>(sink);
|
|
|
|
|
#else
|
|
|
|
|
sink = std::make_shared<spdlog::sinks::ansicolor_sink>(sink);
|
|
|
|
|
#endif
|
|
|
|
@ -72,22 +85,22 @@ inline std::shared_ptr<spdlog::logger> create_console_logger(const std::string&
|
|
|
|
|
|
|
|
|
|
inline std::shared_ptr<spdlog::logger> spdlog::stdout_logger_mt(const std::string& logger_name, bool color)
|
|
|
|
|
{
|
|
|
|
|
return create_console_logger(logger_name, sinks::stdout_sink_mt::instance(), color);
|
|
|
|
|
return create_console_logger_mt(logger_name, sinks::stdout_sink_mt::instance(), color);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline std::shared_ptr<spdlog::logger> spdlog::stdout_logger_st(const std::string& logger_name, bool color)
|
|
|
|
|
{
|
|
|
|
|
return create_console_logger(logger_name, sinks::stdout_sink_st::instance(), color);
|
|
|
|
|
return create_console_logger_st(logger_name, sinks::stdout_sink_st::instance(), color);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline std::shared_ptr<spdlog::logger> spdlog::stderr_logger_mt(const std::string& logger_name, bool color)
|
|
|
|
|
{
|
|
|
|
|
return create_console_logger(logger_name, sinks::stderr_sink_mt::instance(), color);
|
|
|
|
|
return create_console_logger_mt(logger_name, sinks::stderr_sink_mt::instance(), color);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline std::shared_ptr<spdlog::logger> spdlog::stderr_logger_st(const std::string& logger_name, bool color)
|
|
|
|
|
{
|
|
|
|
|
return create_console_logger(logger_name, sinks::stderr_sink_st::instance(), color);
|
|
|
|
|
return create_console_logger_st(logger_name, sinks::stderr_sink_st::instance(), color);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if defined(__linux__) || defined(__APPLE__)
|
|
|
|
|