|
|
@ -18,13 +18,6 @@
|
|
|
|
#include <spdlog/details/log_msg.h>
|
|
|
|
#include <spdlog/details/log_msg.h>
|
|
|
|
#include <spdlog/details/backtracer.h>
|
|
|
|
#include <spdlog/details/backtracer.h>
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef SPDLOG_WCHAR_TO_UTF8_SUPPORT
|
|
|
|
|
|
|
|
# ifndef _WIN32
|
|
|
|
|
|
|
|
# error SPDLOG_WCHAR_TO_UTF8_SUPPORT only supported on windows
|
|
|
|
|
|
|
|
# endif
|
|
|
|
|
|
|
|
# include <spdlog/details/os.h>
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef SPDLOG_NO_EXCEPTIONS
|
|
|
|
#ifndef SPDLOG_NO_EXCEPTIONS
|
|
|
@ -176,91 +169,6 @@ public:
|
|
|
|
log(level::critical, fmt, std::forward<Args>(args)...);
|
|
|
|
log(level::critical, fmt, std::forward<Args>(args)...);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef SPDLOG_WCHAR_TO_UTF8_SUPPORT
|
|
|
|
|
|
|
|
template<typename... Args>
|
|
|
|
|
|
|
|
void log(source_loc loc, level::level_enum lvl, wformat_string_t<Args...> fmt, Args &&...args)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
log_(loc, lvl, details::to_string_view(fmt), std::forward<Args>(args)...);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename... Args>
|
|
|
|
|
|
|
|
void log(level::level_enum lvl, wformat_string_t<Args...> fmt, Args &&...args)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
log(source_loc{}, lvl, fmt, std::forward<Args>(args)...);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void log(log_clock::time_point log_time, source_loc loc, level::level_enum lvl, wstring_view_t msg)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
bool log_enabled = should_log(lvl);
|
|
|
|
|
|
|
|
bool traceback_enabled = tracer_.enabled();
|
|
|
|
|
|
|
|
if (!log_enabled && !traceback_enabled)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
memory_buf_t buf;
|
|
|
|
|
|
|
|
details::os::wstr_to_utf8buf(wstring_view_t(msg.data(), msg.size()), buf);
|
|
|
|
|
|
|
|
details::log_msg log_msg(log_time, loc, name_, lvl, string_view_t(buf.data(), buf.size()));
|
|
|
|
|
|
|
|
log_it_(log_msg, log_enabled, traceback_enabled);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void log(source_loc loc, level::level_enum lvl, wstring_view_t msg)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
bool log_enabled = should_log(lvl);
|
|
|
|
|
|
|
|
bool traceback_enabled = tracer_.enabled();
|
|
|
|
|
|
|
|
if (!log_enabled && !traceback_enabled)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
memory_buf_t buf;
|
|
|
|
|
|
|
|
details::os::wstr_to_utf8buf(wstring_view_t(msg.data(), msg.size()), buf);
|
|
|
|
|
|
|
|
details::log_msg log_msg(loc, name_, lvl, string_view_t(buf.data(), buf.size()));
|
|
|
|
|
|
|
|
log_it_(log_msg, log_enabled, traceback_enabled);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void log(level::level_enum lvl, wstring_view_t msg)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
log(source_loc{}, lvl, msg);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename... Args>
|
|
|
|
|
|
|
|
void trace(wformat_string_t<Args...> fmt, Args &&...args)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
log(level::trace, fmt, std::forward<Args>(args)...);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename... Args>
|
|
|
|
|
|
|
|
void debug(wformat_string_t<Args...> fmt, Args &&...args)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
log(level::debug, fmt, std::forward<Args>(args)...);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename... Args>
|
|
|
|
|
|
|
|
void info(wformat_string_t<Args...> fmt, Args &&...args)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
log(level::info, fmt, std::forward<Args>(args)...);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename... Args>
|
|
|
|
|
|
|
|
void warn(wformat_string_t<Args...> fmt, Args &&...args)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
log(level::warn, fmt, std::forward<Args>(args)...);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename... Args>
|
|
|
|
|
|
|
|
void error(wformat_string_t<Args...> fmt, Args &&...args)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
log(level::err, fmt, std::forward<Args>(args)...);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename... Args>
|
|
|
|
|
|
|
|
void critical(wformat_string_t<Args...> fmt, Args &&...args)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
log(level::critical, fmt, std::forward<Args>(args)...);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
template<typename T>
|
|
|
|
void trace(const T &msg)
|
|
|
|
void trace(const T &msg)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -380,30 +288,6 @@ protected:
|
|
|
|
SPDLOG_LOGGER_CATCH(loc)
|
|
|
|
SPDLOG_LOGGER_CATCH(loc)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef SPDLOG_WCHAR_TO_UTF8_SUPPORT
|
|
|
|
|
|
|
|
template<typename... Args>
|
|
|
|
|
|
|
|
void log_(source_loc loc, level::level_enum lvl, wstring_view_t fmt, Args &&...args)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
bool log_enabled = should_log(lvl);
|
|
|
|
|
|
|
|
bool traceback_enabled = tracer_.enabled();
|
|
|
|
|
|
|
|
if (!log_enabled && !traceback_enabled)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
SPDLOG_TRY
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// format to wmemory_buffer and convert to utf8
|
|
|
|
|
|
|
|
wmemory_buf_t wbuf;
|
|
|
|
|
|
|
|
fmt_lib::vformat_to(std::back_inserter(wbuf), fmt, fmt_lib::make_format_args<fmt_lib::wformat_context>(args...));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
memory_buf_t buf;
|
|
|
|
|
|
|
|
details::os::wstr_to_utf8buf(wstring_view_t(wbuf.data(), wbuf.size()), buf);
|
|
|
|
|
|
|
|
details::log_msg log_msg(loc, name_, lvl, string_view_t(buf.data(), buf.size()));
|
|
|
|
|
|
|
|
log_it_(log_msg, log_enabled, traceback_enabled);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
SPDLOG_LOGGER_CATCH(loc)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // SPDLOG_WCHAR_TO_UTF8_SUPPORT
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// log the given message (if the given log level is high enough),
|
|
|
|
// log the given message (if the given log level is high enough),
|
|
|
|
// and save backtrace (if backtrace is enabled).
|
|
|
|
// and save backtrace (if backtrace is enabled).
|
|
|
|