mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Upgrade spdlog library to 1.12.0
This commit is contained in:
parent
feffcdfa94
commit
7b5f40fb9d
6
r5dev/thirdparty/spdlog/CMakeLists.txt
vendored
6
r5dev/thirdparty/spdlog/CMakeLists.txt
vendored
@ -76,6 +76,7 @@ add_sources( SOURCE_GROUP "FMT"
|
||||
"fmt/fmt.h"
|
||||
"fmt/ostr.h"
|
||||
"fmt/ranges.h"
|
||||
"fmt/std.h"
|
||||
"fmt/xchar.h"
|
||||
)
|
||||
|
||||
@ -93,6 +94,7 @@ add_sources( SOURCE_GROUP "FMT/Bundled"
|
||||
"fmt/bundled/ostream.h"
|
||||
"fmt/bundled/printf.h"
|
||||
"fmt/bundled/ranges.h"
|
||||
"fmt/bundled/std.h"
|
||||
"fmt/bundled/xchar.h"
|
||||
)
|
||||
|
||||
@ -104,10 +106,12 @@ add_sources( SOURCE_GROUP "Sinks"
|
||||
"sinks/base_sink.h"
|
||||
"sinks/basic_file_sink-inl.h"
|
||||
"sinks/basic_file_sink.h"
|
||||
"sinks/callback_sink.h"
|
||||
"sinks/daily_file_sink.h"
|
||||
"sinks/dist_sink.h"
|
||||
"sinks/dup_filter_sink.h"
|
||||
"sinks/hourly_file_sink.h"
|
||||
"sinks/kafka_sink.h"
|
||||
"sinks/mongo_sink.h"
|
||||
"sinks/msvc_sink.h"
|
||||
"sinks/null_sink.h"
|
||||
@ -126,9 +130,9 @@ add_sources( SOURCE_GROUP "Sinks"
|
||||
"sinks/systemd_sink.h"
|
||||
"sinks/tcp_sink.h"
|
||||
"sinks/udp_sink.h"
|
||||
"sinks/win_eventlog_sink.h"
|
||||
"sinks/wincolor_sink-inl.h"
|
||||
"sinks/wincolor_sink.h"
|
||||
"sinks/win_eventlog_sink.h"
|
||||
)
|
||||
|
||||
end_sources()
|
||||
|
6
r5dev/thirdparty/spdlog/async.h
vendored
6
r5dev/thirdparty/spdlog/async.h
vendored
@ -35,7 +35,7 @@ template<async_overflow_policy OverflowPolicy = async_overflow_policy::block>
|
||||
struct async_factory_impl
|
||||
{
|
||||
template<typename Sink, typename... SinkArgs>
|
||||
static std::shared_ptr<async_logger> create(std::string logger_name, SinkArgs &&... args)
|
||||
static std::shared_ptr<async_logger> create(std::string logger_name, SinkArgs &&...args)
|
||||
{
|
||||
auto ®istry_inst = details::registry::instance();
|
||||
|
||||
@ -61,13 +61,13 @@ using async_factory = async_factory_impl<async_overflow_policy::block>;
|
||||
using async_factory_nonblock = async_factory_impl<async_overflow_policy::overrun_oldest>;
|
||||
|
||||
template<typename Sink, typename... SinkArgs>
|
||||
inline std::shared_ptr<spdlog::logger> create_async(std::string logger_name, SinkArgs &&... sink_args)
|
||||
inline std::shared_ptr<spdlog::logger> create_async(std::string logger_name, SinkArgs &&...sink_args)
|
||||
{
|
||||
return async_factory::create<Sink>(std::move(logger_name), std::forward<SinkArgs>(sink_args)...);
|
||||
}
|
||||
|
||||
template<typename Sink, typename... SinkArgs>
|
||||
inline std::shared_ptr<spdlog::logger> create_async_nb(std::string logger_name, SinkArgs &&... sink_args)
|
||||
inline std::shared_ptr<spdlog::logger> create_async_nb(std::string logger_name, SinkArgs &&...sink_args)
|
||||
{
|
||||
return async_factory_nonblock::create<Sink>(std::move(logger_name), std::forward<SinkArgs>(sink_args)...);
|
||||
}
|
||||
|
34
r5dev/thirdparty/spdlog/async_logger-inl.h
vendored
34
r5dev/thirdparty/spdlog/async_logger-inl.h
vendored
@ -24,29 +24,27 @@ SPDLOG_INLINE spdlog::async_logger::async_logger(
|
||||
{}
|
||||
|
||||
// send the log message to the thread pool
|
||||
SPDLOG_INLINE void spdlog::async_logger::sink_it_(const details::log_msg &msg)
|
||||
SPDLOG_INLINE void spdlog::async_logger::sink_it_(const details::log_msg &msg){
|
||||
SPDLOG_TRY{if (auto pool_ptr = thread_pool_.lock()){pool_ptr->post_log(shared_from_this(), msg, overflow_policy_);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (auto pool_ptr = thread_pool_.lock())
|
||||
{
|
||||
pool_ptr->post_log(shared_from_this(), msg, overflow_policy_);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw_spdlog_ex("async log: thread pool doesn't exist anymore");
|
||||
}
|
||||
throw_spdlog_ex("async log: thread pool doesn't exist anymore");
|
||||
}
|
||||
}
|
||||
SPDLOG_LOGGER_CATCH(msg.source)
|
||||
}
|
||||
|
||||
// send flush request to the thread pool
|
||||
SPDLOG_INLINE void spdlog::async_logger::flush_()
|
||||
SPDLOG_INLINE void spdlog::async_logger::flush_(){
|
||||
SPDLOG_TRY{if (auto pool_ptr = thread_pool_.lock()){pool_ptr->post_flush(shared_from_this(), overflow_policy_);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (auto pool_ptr = thread_pool_.lock())
|
||||
{
|
||||
pool_ptr->post_flush(shared_from_this(), overflow_policy_);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw_spdlog_ex("async flush: thread pool doesn't exist anymore");
|
||||
}
|
||||
throw_spdlog_ex("async flush: thread pool doesn't exist anymore");
|
||||
}
|
||||
}
|
||||
SPDLOG_LOGGER_CATCH(source_loc())
|
||||
}
|
||||
|
||||
//
|
||||
|
71
r5dev/thirdparty/spdlog/common.h
vendored
71
r5dev/thirdparty/spdlog/common.h
vendored
@ -17,7 +17,12 @@
|
||||
#include <cstdio>
|
||||
|
||||
#ifdef SPDLOG_USE_STD_FORMAT
|
||||
# include <string_view>
|
||||
# include <version>
|
||||
# if __cpp_lib_format >= 202207L
|
||||
# include <format>
|
||||
# else
|
||||
# include <string_view>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef SPDLOG_COMPILED_LIB
|
||||
@ -59,14 +64,14 @@
|
||||
#if defined(_MSC_VER) && (_MSC_VER < 1900)
|
||||
# define SPDLOG_NOEXCEPT _NOEXCEPT
|
||||
# define SPDLOG_CONSTEXPR
|
||||
# define SPDLOG_CONSTEXPR_FUNC
|
||||
# define SPDLOG_CONSTEXPR_FUNC inline
|
||||
#else
|
||||
# define SPDLOG_NOEXCEPT noexcept
|
||||
# define SPDLOG_CONSTEXPR constexpr
|
||||
# if __cplusplus >= 201402L
|
||||
# define SPDLOG_CONSTEXPR_FUNC constexpr
|
||||
# else
|
||||
# define SPDLOG_CONSTEXPR_FUNC
|
||||
# define SPDLOG_CONSTEXPR_FUNC inline
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@ -102,7 +107,8 @@
|
||||
# define SPDLOG_TRY try
|
||||
# define SPDLOG_THROW(ex) throw(ex)
|
||||
# define SPDLOG_CATCH_STD \
|
||||
catch (const std::exception &) {}
|
||||
catch (const std::exception &) \
|
||||
{}
|
||||
#endif
|
||||
|
||||
namespace spdlog {
|
||||
@ -134,7 +140,11 @@ using string_view_t = std::string_view;
|
||||
using memory_buf_t = std::string;
|
||||
|
||||
template<typename... Args>
|
||||
# if __cpp_lib_format >= 202207L
|
||||
using format_string_t = std::format_string<Args...>;
|
||||
# else
|
||||
using format_string_t = std::string_view;
|
||||
# endif
|
||||
|
||||
template<class T, class Char = char>
|
||||
struct is_convertible_to_basic_format_string : std::integral_constant<bool, std::is_convertible<T, std::basic_string_view<Char>>::value>
|
||||
@ -145,7 +155,11 @@ using wstring_view_t = std::wstring_view;
|
||||
using wmemory_buf_t = std::wstring;
|
||||
|
||||
template<typename... Args>
|
||||
# if __cpp_lib_format >= 202207L
|
||||
using wformat_string_t = std::wformat_string<Args...>;
|
||||
# else
|
||||
using wformat_string_t = std::wstring_view;
|
||||
# endif
|
||||
# endif
|
||||
# define SPDLOG_BUF_TO_STRING(x) x
|
||||
#else // use fmt lib instead of std::format
|
||||
@ -160,12 +174,19 @@ using format_string_t = fmt::format_string<Args...>;
|
||||
template<class T>
|
||||
using remove_cvref_t = typename std::remove_cv<typename std::remove_reference<T>::type>::type;
|
||||
|
||||
template<typename Char>
|
||||
# if FMT_VERSION >= 90101
|
||||
using fmt_runtime_string = fmt::runtime_format_string<Char>;
|
||||
# else
|
||||
using fmt_runtime_string = fmt::basic_runtime<Char>;
|
||||
# endif
|
||||
|
||||
// clang doesn't like SFINAE disabled constructor in std::is_convertible<> so have to repeat the condition from basic_format_string here,
|
||||
// in addition, fmt::basic_runtime<Char> is only convertible to basic_format_string<Char> but not basic_string_view<Char>
|
||||
template<class T, class Char = char>
|
||||
struct is_convertible_to_basic_format_string
|
||||
: std::integral_constant<bool,
|
||||
std::is_convertible<T, fmt::basic_string_view<Char>>::value || std::is_same<remove_cvref_t<T>, fmt::basic_runtime<Char>>::value>
|
||||
std::is_convertible<T, fmt::basic_string_view<Char>>::value || std::is_same<remove_cvref_t<T>, fmt_runtime_string<Char>>::value>
|
||||
{};
|
||||
|
||||
# if defined(SPDLOG_WCHAR_FILENAMES) || defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT)
|
||||
@ -323,6 +344,44 @@ struct file_event_handlers
|
||||
|
||||
namespace details {
|
||||
|
||||
// to_string_view
|
||||
|
||||
SPDLOG_CONSTEXPR_FUNC spdlog::string_view_t to_string_view(const memory_buf_t &buf) SPDLOG_NOEXCEPT
|
||||
{
|
||||
return spdlog::string_view_t{buf.data(), buf.size()};
|
||||
}
|
||||
|
||||
SPDLOG_CONSTEXPR_FUNC spdlog::string_view_t to_string_view(spdlog::string_view_t str) SPDLOG_NOEXCEPT
|
||||
{
|
||||
return str;
|
||||
}
|
||||
|
||||
#if defined(SPDLOG_WCHAR_FILENAMES) || defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT)
|
||||
SPDLOG_CONSTEXPR_FUNC spdlog::wstring_view_t to_string_view(const wmemory_buf_t &buf) SPDLOG_NOEXCEPT
|
||||
{
|
||||
return spdlog::wstring_view_t{buf.data(), buf.size()};
|
||||
}
|
||||
|
||||
SPDLOG_CONSTEXPR_FUNC spdlog::wstring_view_t to_string_view(spdlog::wstring_view_t str) SPDLOG_NOEXCEPT
|
||||
{
|
||||
return str;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef SPDLOG_USE_STD_FORMAT
|
||||
template<typename T, typename... Args>
|
||||
inline fmt::basic_string_view<T> to_string_view(fmt::basic_format_string<T, Args...> fmt)
|
||||
{
|
||||
return fmt;
|
||||
}
|
||||
#elif __cpp_lib_format >= 202207L
|
||||
template<typename T, typename... Args>
|
||||
SPDLOG_CONSTEXPR_FUNC std::basic_string_view<T> to_string_view(std::basic_format_string<T, Args...> fmt) SPDLOG_NOEXCEPT
|
||||
{
|
||||
return fmt.get();
|
||||
}
|
||||
#endif
|
||||
|
||||
// make_unique support for pre c++14
|
||||
|
||||
#if __cplusplus >= 201402L // C++14 and beyond
|
||||
@ -333,7 +392,7 @@ template<bool B, class T = void>
|
||||
using enable_if_t = typename std::enable_if<B, T>::type;
|
||||
|
||||
template<typename T, typename... Args>
|
||||
std::unique_ptr<T> make_unique(Args &&... args)
|
||||
std::unique_ptr<T> make_unique(Args &&...args)
|
||||
{
|
||||
static_assert(!std::is_array<T>::value, "arrays not supported");
|
||||
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
|
||||
|
@ -54,6 +54,12 @@ SPDLOG_INLINE void backtracer::push_back(const log_msg &msg)
|
||||
messages_.push_back(log_msg_buffer{msg});
|
||||
}
|
||||
|
||||
SPDLOG_INLINE bool backtracer::empty() const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock{mutex_};
|
||||
return messages_.empty();
|
||||
}
|
||||
|
||||
// pop all items in the q and apply the given fun on each of them.
|
||||
SPDLOG_INLINE void backtracer::foreach_pop(std::function<void(const details::log_msg &)> fun)
|
||||
{
|
||||
|
1
r5dev/thirdparty/spdlog/details/backtracer.h
vendored
1
r5dev/thirdparty/spdlog/details/backtracer.h
vendored
@ -32,6 +32,7 @@ public:
|
||||
void disable();
|
||||
bool enabled() const;
|
||||
void push_back(const log_msg &msg);
|
||||
bool empty() const;
|
||||
|
||||
// pop all items in the q and apply the given fun on each of them.
|
||||
void foreach_pop(std::function<void(const details::log_msg &)> fun);
|
||||
|
@ -90,6 +90,14 @@ SPDLOG_INLINE void file_helper::flush()
|
||||
}
|
||||
}
|
||||
|
||||
SPDLOG_INLINE void file_helper::sync()
|
||||
{
|
||||
if (!os::fsync(fd_))
|
||||
{
|
||||
throw_spdlog_ex("Failed to fsync file " + os::filename_to_str(filename_), errno);
|
||||
}
|
||||
}
|
||||
|
||||
SPDLOG_INLINE void file_helper::close()
|
||||
{
|
||||
if (fd_ != nullptr)
|
||||
|
@ -26,6 +26,7 @@ public:
|
||||
void open(const filename_t &fname, bool truncate = false);
|
||||
void reopen(bool truncate);
|
||||
void flush();
|
||||
void sync();
|
||||
void close();
|
||||
void write(const memory_buf_t &buf);
|
||||
size_t size() const;
|
||||
|
5
r5dev/thirdparty/spdlog/details/fmt_helper.h
vendored
5
r5dev/thirdparty/spdlog/details/fmt_helper.h
vendored
@ -18,11 +18,6 @@ namespace spdlog {
|
||||
namespace details {
|
||||
namespace fmt_helper {
|
||||
|
||||
inline spdlog::string_view_t to_string_view(const memory_buf_t &buf) SPDLOG_NOEXCEPT
|
||||
{
|
||||
return spdlog::string_view_t{buf.data(), buf.size()};
|
||||
}
|
||||
|
||||
inline void append_string_view(spdlog::string_view_t view, memory_buf_t &dest)
|
||||
{
|
||||
auto *buf_ptr = view.data();
|
||||
|
@ -49,7 +49,7 @@ public:
|
||||
push_cv_.notify_one();
|
||||
}
|
||||
|
||||
// try to dequeue item. if no item found. wait up to timeout and try again
|
||||
// dequeue with a timeout.
|
||||
// Return true, if succeeded dequeue item, false otherwise
|
||||
bool dequeue_for(T &popped_item, std::chrono::milliseconds wait_duration)
|
||||
{
|
||||
@ -66,6 +66,18 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
// blocking dequeue without a timeout.
|
||||
void dequeue(T &popped_item)
|
||||
{
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(queue_mutex_);
|
||||
push_cv_.wait(lock, [this] { return !this->q_.empty(); });
|
||||
popped_item = std::move(q_.front());
|
||||
q_.pop_front();
|
||||
}
|
||||
pop_cv_.notify_one();
|
||||
}
|
||||
|
||||
#else
|
||||
// apparently mingw deadlocks if the mutex is released before cv.notify_one(),
|
||||
// so release the mutex at the very end each function.
|
||||
@ -87,7 +99,7 @@ public:
|
||||
push_cv_.notify_one();
|
||||
}
|
||||
|
||||
// try to dequeue item. if no item found. wait up to timeout and try again
|
||||
// dequeue with a timeout.
|
||||
// Return true, if succeeded dequeue item, false otherwise
|
||||
bool dequeue_for(T &popped_item, std::chrono::milliseconds wait_duration)
|
||||
{
|
||||
@ -102,6 +114,16 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
// blocking dequeue without a timeout.
|
||||
void dequeue(T &popped_item)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(queue_mutex_);
|
||||
push_cv_.wait(lock, [this] { return !this->q_.empty(); });
|
||||
popped_item = std::move(q_.front());
|
||||
q_.pop_front();
|
||||
pop_cv_.notify_one();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
size_t overrun_counter()
|
||||
|
53
r5dev/thirdparty/spdlog/details/os-inl.h
vendored
53
r5dev/thirdparty/spdlog/details/os-inl.h
vendored
@ -23,9 +23,10 @@
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
# include <io.h> // _get_osfhandle and _isatty support
|
||||
# include <process.h> // _get_pid support
|
||||
# include <io.h> // for _get_osfhandle, _isatty, _fileno
|
||||
# include <process.h> // for _get_pid
|
||||
# include <spdlog/details/windows_include.h>
|
||||
# include <fileapi.h> // for FlushFileBuffers
|
||||
|
||||
# ifdef __MINGW32__
|
||||
# include <share.h>
|
||||
@ -33,6 +34,7 @@
|
||||
|
||||
# if defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT) || defined(SPDLOG_WCHAR_FILENAMES)
|
||||
# include <limits>
|
||||
# include <cassert>
|
||||
# endif
|
||||
|
||||
# include <direct.h> // for _mkdir/_wmkdir
|
||||
@ -60,6 +62,10 @@
|
||||
|
||||
#endif // unix
|
||||
|
||||
#if defined __APPLE__
|
||||
# include <AvailabilityMacros.h>
|
||||
#endif
|
||||
|
||||
#ifndef __has_feature // Clang - feature checking macros.
|
||||
# define __has_feature(x) 0 // Compatibility with non-clang compilers.
|
||||
#endif
|
||||
@ -236,8 +242,8 @@ SPDLOG_INLINE size_t filesize(FILE *f)
|
||||
# else
|
||||
int fd = ::fileno(f);
|
||||
# endif
|
||||
// 64 bits(but not in osx or cygwin, where fstat64 is deprecated)
|
||||
# if (defined(__linux__) || defined(__sun) || defined(_AIX)) && (defined(__LP64__) || defined(_LP64))
|
||||
// 64 bits(but not in osx, linux/musl or cygwin, where fstat64 is deprecated)
|
||||
# if ((defined(__linux__) && defined(__GLIBC__)) || defined(__sun) || defined(_AIX)) && (defined(__LP64__) || defined(_LP64))
|
||||
struct stat64 st;
|
||||
if (::fstat64(fd, &st) == 0)
|
||||
{
|
||||
@ -286,7 +292,8 @@ SPDLOG_INLINE int utc_minutes_offset(const std::tm &tm)
|
||||
return offset;
|
||||
#else
|
||||
|
||||
# if defined(sun) || defined(__sun) || defined(_AIX) || (!defined(_BSD_SOURCE) && !defined(_GNU_SOURCE))
|
||||
# if defined(sun) || defined(__sun) || defined(_AIX) || (defined(__NEWLIB__) && !defined(__TM_GMTOFF)) || \
|
||||
(!defined(_BSD_SOURCE) && !defined(_GNU_SOURCE))
|
||||
// 'tm_gmtoff' field is BSD extension and it's missing on SunOS/Solaris
|
||||
struct helper
|
||||
{
|
||||
@ -353,7 +360,22 @@ SPDLOG_INLINE size_t _thread_id() SPDLOG_NOEXCEPT
|
||||
return static_cast<size_t>(::thr_self());
|
||||
#elif __APPLE__
|
||||
uint64_t tid;
|
||||
// There is no pthread_threadid_np prior to 10.6, and it is not supported on any PPC,
|
||||
// including 10.6.8 Rosetta. __POWERPC__ is Apple-specific define encompassing ppc and ppc64.
|
||||
# if (MAC_OS_X_VERSION_MAX_ALLOWED < 1060) || defined(__POWERPC__)
|
||||
tid = pthread_mach_thread_np(pthread_self());
|
||||
# elif MAC_OS_X_VERSION_MIN_REQUIRED < 1060
|
||||
if (&pthread_threadid_np)
|
||||
{
|
||||
pthread_threadid_np(nullptr, &tid);
|
||||
}
|
||||
else
|
||||
{
|
||||
tid = pthread_mach_thread_np(pthread_self());
|
||||
}
|
||||
# else
|
||||
pthread_threadid_np(nullptr, &tid);
|
||||
# endif
|
||||
return static_cast<size_t>(tid);
|
||||
#else // Default to standard C++11 (other Unix)
|
||||
return static_cast<size_t>(std::hash<std::thread::id>()(std::this_thread::get_id()));
|
||||
@ -500,20 +522,16 @@ SPDLOG_INLINE void utf8_to_wstrbuf(string_view_t str, wmemory_buf_t &target)
|
||||
return;
|
||||
}
|
||||
|
||||
int result_size = static_cast<int>(target.capacity());
|
||||
if (str_size + 1 > result_size)
|
||||
{
|
||||
result_size = ::MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, str.data(), str_size, NULL, 0);
|
||||
}
|
||||
// find the size to allocate for the result buffer
|
||||
int result_size = ::MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, str.data(), str_size, NULL, 0);
|
||||
|
||||
if (result_size > 0)
|
||||
{
|
||||
target.resize(result_size);
|
||||
result_size = ::MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, str.data(), str_size, target.data(), result_size);
|
||||
|
||||
if (result_size > 0)
|
||||
{
|
||||
target.resize(result_size);
|
||||
assert(result_size == target.size());
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -601,6 +619,17 @@ std::string SPDLOG_INLINE getenv(const char *field)
|
||||
#endif
|
||||
}
|
||||
|
||||
// Do fsync by FILE handlerpointer
|
||||
// Return true on success
|
||||
SPDLOG_INLINE bool fsync(FILE *fp)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return FlushFileBuffers(reinterpret_cast<HANDLE>(_get_osfhandle(_fileno(fp)))) != 0;
|
||||
#else
|
||||
return ::fsync(fileno(fp)) == 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace os
|
||||
} // namespace details
|
||||
} // namespace spdlog
|
||||
|
4
r5dev/thirdparty/spdlog/details/os.h
vendored
4
r5dev/thirdparty/spdlog/details/os.h
vendored
@ -109,6 +109,10 @@ SPDLOG_API bool create_dir(const filename_t &path);
|
||||
// return empty string if field not found
|
||||
SPDLOG_API std::string getenv(const char *field);
|
||||
|
||||
// Do fsync by FILE objectpointer.
|
||||
// Return true on success.
|
||||
SPDLOG_API bool fsync(FILE *fp);
|
||||
|
||||
} // namespace os
|
||||
} // namespace details
|
||||
} // namespace spdlog
|
||||
|
11
r5dev/thirdparty/spdlog/details/registry-inl.h
vendored
11
r5dev/thirdparty/spdlog/details/registry-inl.h
vendored
@ -219,8 +219,9 @@ SPDLOG_INLINE void registry::flush_all()
|
||||
SPDLOG_INLINE void registry::drop(const std::string &logger_name)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(logger_map_mutex_);
|
||||
auto is_default_logger = default_logger_ && default_logger_->name() == logger_name;
|
||||
loggers_.erase(logger_name);
|
||||
if (default_logger_ && default_logger_->name() == logger_name)
|
||||
if (is_default_logger)
|
||||
{
|
||||
default_logger_.reset();
|
||||
}
|
||||
@ -287,6 +288,14 @@ SPDLOG_INLINE registry ®istry::instance()
|
||||
return s_instance;
|
||||
}
|
||||
|
||||
SPDLOG_INLINE void registry::apply_logger_env_levels(std::shared_ptr<logger> new_logger)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(logger_map_mutex_);
|
||||
auto it = log_levels_.find(new_logger->name());
|
||||
auto new_level = it != log_levels_.end() ? it->second : global_log_level_;
|
||||
new_logger->set_level(new_level);
|
||||
}
|
||||
|
||||
SPDLOG_INLINE void registry::throw_if_exists_(const std::string &logger_name)
|
||||
{
|
||||
if (loggers_.find(logger_name) != loggers_.end())
|
||||
|
2
r5dev/thirdparty/spdlog/details/registry.h
vendored
2
r5dev/thirdparty/spdlog/details/registry.h
vendored
@ -91,6 +91,8 @@ public:
|
||||
|
||||
static registry &instance();
|
||||
|
||||
void apply_logger_env_levels(std::shared_ptr<logger> new_logger);
|
||||
|
||||
private:
|
||||
registry();
|
||||
~registry();
|
||||
|
@ -13,7 +13,7 @@ class logger;
|
||||
struct synchronous_factory
|
||||
{
|
||||
template<typename Sink, typename... SinkArgs>
|
||||
static std::shared_ptr<spdlog::logger> create(std::string logger_name, SinkArgs &&... args)
|
||||
static std::shared_ptr<spdlog::logger> create(std::string logger_name, SinkArgs &&...args)
|
||||
{
|
||||
auto sink = std::make_shared<Sink>(std::forward<SinkArgs>(args)...);
|
||||
auto new_logger = std::make_shared<spdlog::logger>(std::move(logger_name), std::move(sink));
|
||||
|
@ -83,7 +83,7 @@ public:
|
||||
{};
|
||||
ZeroMemory(&hints, sizeof(hints));
|
||||
|
||||
hints.ai_family = AF_INET; // IPv4
|
||||
hints.ai_family = AF_UNSPEC; // To work with IPv4, IPv6, and so on
|
||||
hints.ai_socktype = SOCK_STREAM; // TCP
|
||||
hints.ai_flags = AI_NUMERICSERV; // port passed as as numeric value
|
||||
hints.ai_protocol = 0;
|
||||
|
5
r5dev/thirdparty/spdlog/details/tcp_client.h
vendored
5
r5dev/thirdparty/spdlog/details/tcp_client.h
vendored
@ -16,6 +16,7 @@
|
||||
#include <unistd.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
@ -57,7 +58,7 @@ public:
|
||||
struct addrinfo hints
|
||||
{};
|
||||
memset(&hints, 0, sizeof(struct addrinfo));
|
||||
hints.ai_family = AF_INET; // IPv4
|
||||
hints.ai_family = AF_UNSPEC; // To work with IPv4, IPv6, and so on
|
||||
hints.ai_socktype = SOCK_STREAM; // TCP
|
||||
hints.ai_flags = AI_NUMERICSERV; // port passed as as numeric value
|
||||
hints.ai_protocol = 0;
|
||||
@ -110,7 +111,7 @@ public:
|
||||
#endif
|
||||
|
||||
#if !defined(SO_NOSIGPIPE) && !defined(MSG_NOSIGNAL)
|
||||
# error "tcp_sink would raise SIGPIPE since niether SO_NOSIGPIPE nor MSG_NOSIGNAL are available"
|
||||
# error "tcp_sink would raise SIGPIPE since neither SO_NOSIGPIPE nor MSG_NOSIGNAL are available"
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -108,11 +108,7 @@ void SPDLOG_INLINE thread_pool::worker_loop_()
|
||||
bool SPDLOG_INLINE thread_pool::process_next_msg_()
|
||||
{
|
||||
async_msg incoming_async_msg;
|
||||
bool dequeued = q_.dequeue_for(incoming_async_msg, std::chrono::seconds(10));
|
||||
if (!dequeued)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
q_.dequeue(incoming_async_msg);
|
||||
|
||||
switch (incoming_async_msg.msg_type)
|
||||
{
|
||||
|
@ -15,9 +15,11 @@
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
|
||||
#pragma comment(lib, "Ws2_32.lib")
|
||||
#pragma comment(lib, "Mswsock.lib")
|
||||
#pragma comment(lib, "AdvApi32.lib")
|
||||
#if defined(_MSC_VER)
|
||||
# pragma comment(lib, "Ws2_32.lib")
|
||||
# pragma comment(lib, "Mswsock.lib")
|
||||
# pragma comment(lib, "AdvApi32.lib")
|
||||
#endif
|
||||
|
||||
namespace spdlog {
|
||||
namespace details {
|
||||
@ -25,7 +27,7 @@ class udp_client
|
||||
{
|
||||
static constexpr int TX_BUFFER_SIZE = 1024 * 10;
|
||||
SOCKET socket_ = INVALID_SOCKET;
|
||||
sockaddr_in addr_ = {0};
|
||||
sockaddr_in addr_ = {};
|
||||
|
||||
static void init_winsock_()
|
||||
{
|
||||
|
2
r5dev/thirdparty/spdlog/details/udp_client.h
vendored
2
r5dev/thirdparty/spdlog/details/udp_client.h
vendored
@ -12,7 +12,7 @@
|
||||
|
||||
#include <spdlog/common.h>
|
||||
#include <spdlog/details/os.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
6
r5dev/thirdparty/spdlog/fmt/bin_to_hex.h
vendored
6
r5dev/thirdparty/spdlog/fmt/bin_to_hex.h
vendored
@ -156,7 +156,7 @@ struct formatter<spdlog::details::dump_info<T>, char>
|
||||
|
||||
// format the given bytes range as hex
|
||||
template<typename FormatContext, typename Container>
|
||||
auto format(const spdlog::details::dump_info<Container> &the_range, FormatContext &ctx) -> decltype(ctx.out())
|
||||
auto format(const spdlog::details::dump_info<Container> &the_range, FormatContext &ctx) const -> decltype(ctx.out())
|
||||
{
|
||||
SPDLOG_CONSTEXPR const char *hex_upper = "0123456789ABCDEF";
|
||||
SPDLOG_CONSTEXPR const char *hex_lower = "0123456789abcdef";
|
||||
@ -196,7 +196,7 @@ struct formatter<spdlog::details::dump_info<T>, char>
|
||||
continue;
|
||||
}
|
||||
|
||||
if (put_delimiters)
|
||||
if (put_delimiters && i != the_range.get_begin())
|
||||
{
|
||||
*inserter++ = delimiter;
|
||||
}
|
||||
@ -232,7 +232,7 @@ struct formatter<spdlog::details::dump_info<T>, char>
|
||||
|
||||
// put newline(and position header)
|
||||
template<typename It>
|
||||
void put_newline(It inserter, std::size_t pos)
|
||||
void put_newline(It inserter, std::size_t pos) const
|
||||
{
|
||||
#ifdef _WIN32
|
||||
*inserter++ = '\r';
|
||||
|
9
r5dev/thirdparty/spdlog/fmt/bundled/core.h
vendored
9
r5dev/thirdparty/spdlog/fmt/bundled/core.h
vendored
@ -3004,14 +3004,7 @@ void check_format_string(S format_str) {
|
||||
FMT_CONSTEXPR auto s = basic_string_view<typename S::char_type>(format_str);
|
||||
using checker = format_string_checker<typename S::char_type, error_handler,
|
||||
remove_cvref_t<Args>...>;
|
||||
|
||||
#if (FMT_MSC_VERSION == 0 || FMT_MSC_VERSION > 1913)
|
||||
FMT_CONSTEXPR
|
||||
#else
|
||||
// Don't qualify as constexpr as older visual studio compilers will
|
||||
// throw the error C2131 'expression did not evaluate to a constant'.
|
||||
#endif
|
||||
bool invalid_format =
|
||||
FMT_CONSTEXPR bool invalid_format =
|
||||
(parse_format_string<true>(s, checker(s, {})), true);
|
||||
ignore_unused(invalid_format);
|
||||
}
|
||||
|
171
r5dev/thirdparty/spdlog/fmt/bundled/std.h
vendored
Normal file
171
r5dev/thirdparty/spdlog/fmt/bundled/std.h
vendored
Normal file
@ -0,0 +1,171 @@
|
||||
// Formatting library for C++ - formatters for standard library types
|
||||
//
|
||||
// Copyright (c) 2012 - present, Victor Zverovich
|
||||
// All rights reserved.
|
||||
//
|
||||
// For the license information refer to format.h.
|
||||
|
||||
#ifndef FMT_STD_H_
|
||||
#define FMT_STD_H_
|
||||
|
||||
#include <thread>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
#include "ostream.h"
|
||||
|
||||
#if FMT_HAS_INCLUDE(<version>)
|
||||
# include <version>
|
||||
#endif
|
||||
// Checking FMT_CPLUSPLUS for warning suppression in MSVC.
|
||||
#if FMT_CPLUSPLUS >= 201703L
|
||||
# if FMT_HAS_INCLUDE(<filesystem>)
|
||||
# include <filesystem>
|
||||
# endif
|
||||
# if FMT_HAS_INCLUDE(<variant>)
|
||||
# include <variant>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef __cpp_lib_filesystem
|
||||
FMT_BEGIN_NAMESPACE
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename Char>
|
||||
void write_escaped_path(basic_memory_buffer<Char>& quoted,
|
||||
const std::filesystem::path& p) {
|
||||
write_escaped_string<Char>(std::back_inserter(quoted), p.string<Char>());
|
||||
}
|
||||
# ifdef _WIN32
|
||||
template <>
|
||||
inline void write_escaped_path<char>(basic_memory_buffer<char>& quoted,
|
||||
const std::filesystem::path& p) {
|
||||
auto s = p.u8string();
|
||||
write_escaped_string<char>(
|
||||
std::back_inserter(quoted),
|
||||
string_view(reinterpret_cast<const char*>(s.c_str()), s.size()));
|
||||
}
|
||||
# endif
|
||||
template <>
|
||||
inline void write_escaped_path<std::filesystem::path::value_type>(
|
||||
basic_memory_buffer<std::filesystem::path::value_type>& quoted,
|
||||
const std::filesystem::path& p) {
|
||||
write_escaped_string<std::filesystem::path::value_type>(
|
||||
std::back_inserter(quoted), p.native());
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <typename Char>
|
||||
struct formatter<std::filesystem::path, Char>
|
||||
: formatter<basic_string_view<Char>> {
|
||||
template <typename FormatContext>
|
||||
auto format(const std::filesystem::path& p, FormatContext& ctx) const ->
|
||||
typename FormatContext::iterator {
|
||||
basic_memory_buffer<Char> quoted;
|
||||
detail::write_escaped_path(quoted, p);
|
||||
return formatter<basic_string_view<Char>>::format(
|
||||
basic_string_view<Char>(quoted.data(), quoted.size()), ctx);
|
||||
}
|
||||
};
|
||||
FMT_END_NAMESPACE
|
||||
#endif
|
||||
|
||||
FMT_BEGIN_NAMESPACE
|
||||
template <typename Char>
|
||||
struct formatter<std::thread::id, Char> : basic_ostream_formatter<Char> {};
|
||||
FMT_END_NAMESPACE
|
||||
|
||||
#ifdef __cpp_lib_variant
|
||||
FMT_BEGIN_NAMESPACE
|
||||
template <typename Char> struct formatter<std::monostate, Char> {
|
||||
template <typename ParseContext>
|
||||
FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) {
|
||||
return ctx.begin();
|
||||
}
|
||||
|
||||
template <typename FormatContext>
|
||||
auto format(const std::monostate&, FormatContext& ctx) const
|
||||
-> decltype(ctx.out()) {
|
||||
auto out = ctx.out();
|
||||
out = detail::write<Char>(out, "monostate");
|
||||
return out;
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename T>
|
||||
using variant_index_sequence =
|
||||
std::make_index_sequence<std::variant_size<T>::value>;
|
||||
|
||||
// variant_size and variant_alternative check.
|
||||
template <typename T, typename U = void>
|
||||
struct is_variant_like_ : std::false_type {};
|
||||
template <typename T>
|
||||
struct is_variant_like_<T, std::void_t<decltype(std::variant_size<T>::value)>>
|
||||
: std::true_type {};
|
||||
|
||||
// formattable element check
|
||||
template <typename T, typename C> class is_variant_formattable_ {
|
||||
template <std::size_t... I>
|
||||
static std::conjunction<
|
||||
is_formattable<std::variant_alternative_t<I, T>, C>...>
|
||||
check(std::index_sequence<I...>);
|
||||
|
||||
public:
|
||||
static constexpr const bool value =
|
||||
decltype(check(variant_index_sequence<T>{}))::value;
|
||||
};
|
||||
|
||||
template <typename Char, typename OutputIt, typename T>
|
||||
auto write_variant_alternative(OutputIt out, const T& v) -> OutputIt {
|
||||
if constexpr (is_string<T>::value)
|
||||
return write_escaped_string<Char>(out, detail::to_string_view(v));
|
||||
else if constexpr (std::is_same_v<T, Char>)
|
||||
return write_escaped_char(out, v);
|
||||
else
|
||||
return write<Char>(out, v);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <typename T> struct is_variant_like {
|
||||
static constexpr const bool value = detail::is_variant_like_<T>::value;
|
||||
};
|
||||
|
||||
template <typename T, typename C> struct is_variant_formattable {
|
||||
static constexpr const bool value =
|
||||
detail::is_variant_formattable_<T, C>::value;
|
||||
};
|
||||
|
||||
template <typename Variant, typename Char>
|
||||
struct formatter<
|
||||
Variant, Char,
|
||||
std::enable_if_t<std::conjunction_v<
|
||||
is_variant_like<Variant>, is_variant_formattable<Variant, Char>>>> {
|
||||
template <typename ParseContext>
|
||||
FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) {
|
||||
return ctx.begin();
|
||||
}
|
||||
|
||||
template <typename FormatContext>
|
||||
auto format(const Variant& value, FormatContext& ctx) const
|
||||
-> decltype(ctx.out()) {
|
||||
auto out = ctx.out();
|
||||
|
||||
out = detail::write<Char>(out, "variant(");
|
||||
std::visit(
|
||||
[&](const auto& v) {
|
||||
out = detail::write_variant_alternative<Char>(out, v);
|
||||
},
|
||||
value);
|
||||
*out++ = ')';
|
||||
return out;
|
||||
}
|
||||
};
|
||||
FMT_END_NAMESPACE
|
||||
#endif
|
||||
|
||||
#endif // FMT_STD_H_
|
23
r5dev/thirdparty/spdlog/fmt/std.h
vendored
Normal file
23
r5dev/thirdparty/spdlog/fmt/std.h
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
//
|
||||
// Copyright(c) 2016 Gabi Melman.
|
||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||
//
|
||||
|
||||
#pragma once
|
||||
//
|
||||
// include bundled or external copy of fmtlib's std support (for formatting e.g. std::filesystem::path, std::thread::id, std::monostate,
|
||||
// std::variant, ...)
|
||||
//
|
||||
|
||||
#if !defined(SPDLOG_USE_STD_FORMAT)
|
||||
# if !defined(SPDLOG_FMT_EXTERNAL)
|
||||
# ifdef SPDLOG_HEADER_ONLY
|
||||
# ifndef FMT_HEADER_ONLY
|
||||
# define FMT_HEADER_ONLY
|
||||
# endif
|
||||
# endif
|
||||
# include <spdlog/fmt/bundled/std.h>
|
||||
# else
|
||||
# include <fmt/std.h>
|
||||
# endif
|
||||
#endif
|
6
r5dev/thirdparty/spdlog/logger-inl.h
vendored
6
r5dev/thirdparty/spdlog/logger-inl.h
vendored
@ -210,7 +210,7 @@ SPDLOG_INLINE void logger::flush_()
|
||||
SPDLOG_INLINE void logger::dump_backtrace_()
|
||||
{
|
||||
using details::log_msg;
|
||||
if (tracer_.enabled())
|
||||
if (tracer_.enabled() && !tracer_.empty())
|
||||
{
|
||||
sink_it_(log_msg{name(), level::info, "****************** Backtrace Start ******************"});
|
||||
tracer_.foreach_pop([this](const log_msg &msg) { this->sink_it_(msg); });
|
||||
@ -248,9 +248,9 @@ SPDLOG_INLINE void logger::err_handler_(const std::string &msg)
|
||||
char date_buf[64];
|
||||
std::strftime(date_buf, sizeof(date_buf), "%Y-%m-%d %H:%M:%S", &tm_time);
|
||||
#if defined(USING_R) && defined(R_R_H) // if in R environment
|
||||
REprintf("[*** LOG ERROR #%04zu ***] [%s] [%s] {%s}\n", err_counter, date_buf, name().c_str(), msg.c_str());
|
||||
REprintf("[*** LOG ERROR #%04zu ***] [%s] [%s] %s\n", err_counter, date_buf, name().c_str(), msg.c_str());
|
||||
#else
|
||||
std::fprintf(stderr, "[*** LOG ERROR #%04zu ***] [%s] [%s] {%s}\n", err_counter, date_buf, name().c_str(), msg.c_str());
|
||||
std::fprintf(stderr, "[*** LOG ERROR #%04zu ***] [%s] [%s] %s\n", err_counter, date_buf, name().c_str(), msg.c_str());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
72
r5dev/thirdparty/spdlog/logger.h
vendored
72
r5dev/thirdparty/spdlog/logger.h
vendored
@ -85,13 +85,13 @@ public:
|
||||
void swap(spdlog::logger &other) SPDLOG_NOEXCEPT;
|
||||
|
||||
template<typename... Args>
|
||||
void log(source_loc loc, level::level_enum lvl, format_string_t<Args...> fmt, Args &&... args)
|
||||
void log(source_loc loc, level::level_enum lvl, format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
log_(loc, lvl, fmt, std::forward<Args>(args)...);
|
||||
log_(loc, lvl, details::to_string_view(fmt), std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
void log(level::level_enum lvl, format_string_t<Args...> fmt, Args &&... args)
|
||||
void log(level::level_enum lvl, format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
log(source_loc{}, lvl, fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
@ -141,50 +141,50 @@ public:
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
void trace(format_string_t<Args...> fmt, Args &&... args)
|
||||
void trace(format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
log(level::trace, fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
void debug(format_string_t<Args...> fmt, Args &&... args)
|
||||
void debug(format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
log(level::debug, fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
void info(format_string_t<Args...> fmt, Args &&... args)
|
||||
void info(format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
log(level::info, fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
void warn(format_string_t<Args...> fmt, Args &&... args)
|
||||
void warn(format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
log(level::warn, fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
void error(format_string_t<Args...> fmt, Args &&... args)
|
||||
void error(format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
log(level::err, fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
void critical(format_string_t<Args...> fmt, Args &&... args)
|
||||
void critical(format_string_t<Args...> fmt, 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)
|
||||
void log(source_loc loc, level::level_enum lvl, wformat_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
log_(loc, lvl, fmt, std::forward<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)
|
||||
void log(level::level_enum lvl, wformat_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
log(source_loc{}, lvl, fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
@ -225,37 +225,37 @@ public:
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
void trace(wformat_string_t<Args...> fmt, Args &&... 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)
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
void critical(wformat_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
log(level::critical, fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
@ -357,7 +357,7 @@ protected:
|
||||
|
||||
// common implementation for after templated public api has been resolved
|
||||
template<typename... Args>
|
||||
void log_(source_loc loc, level::level_enum lvl, string_view_t fmt, Args &&... args)
|
||||
void log_(source_loc loc, level::level_enum lvl, string_view_t fmt, Args &&...args)
|
||||
{
|
||||
bool log_enabled = should_log(lvl);
|
||||
bool traceback_enabled = tracer_.enabled();
|
||||
@ -369,9 +369,9 @@ protected:
|
||||
{
|
||||
memory_buf_t buf;
|
||||
#ifdef SPDLOG_USE_STD_FORMAT
|
||||
fmt_lib::vformat_to(std::back_inserter(buf), fmt, fmt_lib::make_format_args(std::forward<Args>(args)...));
|
||||
fmt_lib::vformat_to(std::back_inserter(buf), fmt, fmt_lib::make_format_args(args...));
|
||||
#else
|
||||
fmt::vformat_to(fmt::appender(buf), fmt, fmt::make_format_args(std::forward<Args>(args)...));
|
||||
fmt::vformat_to(fmt::appender(buf), fmt, fmt::make_format_args(args...));
|
||||
#endif
|
||||
|
||||
details::log_msg log_msg(loc, name_, lvl, string_view_t(buf.data(), buf.size()));
|
||||
@ -382,7 +382,7 @@ protected:
|
||||
|
||||
#ifdef SPDLOG_WCHAR_TO_UTF8_SUPPORT
|
||||
template<typename... Args>
|
||||
void log_(source_loc loc, level::level_enum lvl, wstring_view_t fmt, Args &&... 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();
|
||||
@ -394,12 +394,7 @@ protected:
|
||||
{
|
||||
// format to wmemory_buffer and convert to utf8
|
||||
wmemory_buf_t wbuf;
|
||||
# ifdef SPDLOG_USE_STD_FORMAT
|
||||
fmt_lib::vformat_to(
|
||||
std::back_inserter(wbuf), fmt, fmt_lib::make_format_args<fmt_lib::wformat_context>(std::forward<Args>(args)...));
|
||||
# else
|
||||
fmt::vformat_to(std::back_inserter(wbuf), fmt, fmt::make_format_args<fmt::wformat_context>(std::forward<Args>(args)...));
|
||||
# endif
|
||||
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);
|
||||
@ -408,27 +403,6 @@ protected:
|
||||
}
|
||||
SPDLOG_LOGGER_CATCH(loc)
|
||||
}
|
||||
|
||||
// T can be statically converted to wstring_view, and no formatting needed.
|
||||
template<class T, typename std::enable_if<std::is_convertible<const T &, spdlog::wstring_view_t>::value, int>::type = 0>
|
||||
void log_(source_loc loc, level::level_enum lvl, const T &msg)
|
||||
{
|
||||
bool log_enabled = should_log(lvl);
|
||||
bool traceback_enabled = tracer_.enabled();
|
||||
if (!log_enabled && !traceback_enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
SPDLOG_TRY
|
||||
{
|
||||
memory_buf_t buf;
|
||||
details::os::wstr_to_utf8buf(msg, 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),
|
||||
|
2
r5dev/thirdparty/spdlog/pattern_formatter.h
vendored
2
r5dev/thirdparty/spdlog/pattern_formatter.h
vendored
@ -92,7 +92,7 @@ public:
|
||||
void format(const details::log_msg &msg, memory_buf_t &dest) override;
|
||||
|
||||
template<typename T, typename... Args>
|
||||
pattern_formatter &add_flag(char flag, Args &&... args)
|
||||
pattern_formatter &add_flag(char flag, Args &&...args)
|
||||
{
|
||||
custom_handlers_[flag] = details::make_unique<T>(std::forward<Args>(args)...);
|
||||
return *this;
|
||||
|
8
r5dev/thirdparty/spdlog/sinks/android_sink.h
vendored
8
r5dev/thirdparty/spdlog/sinks/android_sink.h
vendored
@ -56,6 +56,10 @@ protected:
|
||||
|
||||
// See system/core/liblog/logger_write.c for explanation of return value
|
||||
int ret = android_log(priority, tag_.c_str(), msg_output);
|
||||
if (ret == -EPERM)
|
||||
{
|
||||
return; // !__android_log_is_loggable
|
||||
}
|
||||
int retry_count = 0;
|
||||
while ((ret == -11 /*EAGAIN*/) && (retry_count < SPDLOG_ANDROID_RETRIES))
|
||||
{
|
||||
@ -74,7 +78,7 @@ protected:
|
||||
|
||||
private:
|
||||
// There might be liblog versions used, that do not support __android_log_buf_write. So we only compile and link against
|
||||
// __android_log_buf_write, if user explicitely provides a non-default log buffer. Otherwise, when using the default log buffer, always
|
||||
// __android_log_buf_write, if user explicitly provides a non-default log buffer. Otherwise, when using the default log buffer, always
|
||||
// log via __android_log_write.
|
||||
template<int ID = BufferID>
|
||||
typename std::enable_if<ID == static_cast<int>(log_id::LOG_ID_MAIN), int>::type android_log(int prio, const char *tag, const char *text)
|
||||
@ -139,4 +143,4 @@ inline std::shared_ptr<logger> android_logger_st(const std::string &logger_name,
|
||||
|
||||
} // namespace spdlog
|
||||
|
||||
#endif // __ANDROID__
|
||||
#endif // __ANDROID__
|
||||
|
@ -21,20 +21,20 @@ SPDLOG_INLINE ansicolor_sink<ConsoleMutex>::ansicolor_sink(FILE *target_file, co
|
||||
|
||||
{
|
||||
set_color_mode(mode);
|
||||
colors_[level::trace] = to_string_(white);
|
||||
colors_[level::debug] = to_string_(cyan);
|
||||
colors_[level::info] = to_string_(green);
|
||||
colors_[level::warn] = to_string_(yellow_bold);
|
||||
colors_[level::err] = to_string_(red_bold);
|
||||
colors_[level::critical] = to_string_(bold_on_red);
|
||||
colors_[level::off] = to_string_(reset);
|
||||
colors_.at(level::trace) = to_string_(white);
|
||||
colors_.at(level::debug) = to_string_(cyan);
|
||||
colors_.at(level::info) = to_string_(green);
|
||||
colors_.at(level::warn) = to_string_(yellow_bold);
|
||||
colors_.at(level::err) = to_string_(red_bold);
|
||||
colors_.at(level::critical) = to_string_(bold_on_red);
|
||||
colors_.at(level::off) = to_string_(reset);
|
||||
}
|
||||
|
||||
template<typename ConsoleMutex>
|
||||
SPDLOG_INLINE void ansicolor_sink<ConsoleMutex>::set_color(level::level_enum color_level, string_view_t color)
|
||||
{
|
||||
std::lock_guard<mutex_t> lock(mutex_);
|
||||
colors_[static_cast<size_t>(color_level)] = to_string_(color);
|
||||
colors_.at(static_cast<size_t>(color_level)) = to_string_(color);
|
||||
}
|
||||
|
||||
template<typename ConsoleMutex>
|
||||
@ -52,7 +52,7 @@ SPDLOG_INLINE void ansicolor_sink<ConsoleMutex>::log(const details::log_msg &msg
|
||||
// before color range
|
||||
print_range_(formatted, 0, msg.color_range_start);
|
||||
// in color range
|
||||
print_ccode_(colors_[static_cast<size_t>(msg.level)]);
|
||||
print_ccode_(colors_.at(static_cast<size_t>(msg.level)));
|
||||
print_range_(formatted, msg.color_range_start, msg.color_range_end);
|
||||
print_ccode_(reset);
|
||||
// after color range
|
||||
|
61
r5dev/thirdparty/spdlog/sinks/callback_sink.h
vendored
Normal file
61
r5dev/thirdparty/spdlog/sinks/callback_sink.h
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
|
||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <spdlog/details/null_mutex.h>
|
||||
#include <spdlog/sinks/base_sink.h>
|
||||
#include <spdlog/details/synchronous_factory.h>
|
||||
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
namespace spdlog {
|
||||
|
||||
// callbacks type
|
||||
typedef std::function<void(const details::log_msg &msg)> custom_log_callback;
|
||||
|
||||
namespace sinks {
|
||||
/*
|
||||
* Trivial callback sink, gets a callback function and calls it on each log
|
||||
*/
|
||||
template<typename Mutex>
|
||||
class callback_sink final : public base_sink<Mutex>
|
||||
{
|
||||
public:
|
||||
explicit callback_sink(const custom_log_callback &callback)
|
||||
: callback_{callback}
|
||||
{}
|
||||
|
||||
protected:
|
||||
void sink_it_(const details::log_msg &msg) override
|
||||
{
|
||||
callback_(msg);
|
||||
}
|
||||
void flush_() override{};
|
||||
|
||||
private:
|
||||
custom_log_callback callback_;
|
||||
};
|
||||
|
||||
using callback_sink_mt = callback_sink<std::mutex>;
|
||||
using callback_sink_st = callback_sink<details::null_mutex>;
|
||||
|
||||
} // namespace sinks
|
||||
|
||||
//
|
||||
// factory functions
|
||||
//
|
||||
template<typename Factory = spdlog::synchronous_factory>
|
||||
inline std::shared_ptr<logger> callback_logger_mt(const std::string &logger_name, const custom_log_callback &callback)
|
||||
{
|
||||
return Factory::template create<sinks::callback_sink_mt>(logger_name, callback);
|
||||
}
|
||||
|
||||
template<typename Factory = spdlog::synchronous_factory>
|
||||
inline std::shared_ptr<logger> callback_logger_st(const std::string &logger_name, const custom_log_callback &callback)
|
||||
{
|
||||
return Factory::template create<sinks::callback_sink_st>(logger_name, callback);
|
||||
}
|
||||
|
||||
} // namespace spdlog
|
66
r5dev/thirdparty/spdlog/sinks/daily_file_sink.h
vendored
66
r5dev/thirdparty/spdlog/sinks/daily_file_sink.h
vendored
@ -13,9 +13,10 @@
|
||||
#include <spdlog/details/circular_q.h>
|
||||
#include <spdlog/details/synchronous_factory.h>
|
||||
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <chrono>
|
||||
#include <cstdio>
|
||||
#include <ctime>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
@ -46,67 +47,16 @@ struct daily_filename_calculator
|
||||
*/
|
||||
struct daily_filename_format_calculator
|
||||
{
|
||||
static filename_t calc_filename(const filename_t &filename, const tm &now_tm)
|
||||
static filename_t calc_filename(const filename_t &file_path, const tm &now_tm)
|
||||
{
|
||||
#ifdef SPDLOG_USE_STD_FORMAT
|
||||
// adapted from fmtlib: https://github.com/fmtlib/fmt/blob/8.0.1/include/fmt/chrono.h#L522-L546
|
||||
|
||||
filename_t tm_format;
|
||||
tm_format.append(filename);
|
||||
// By appending an extra space we can distinguish an empty result that
|
||||
// indicates insufficient buffer size from a guaranteed non-empty result
|
||||
// https://github.com/fmtlib/fmt/issues/2238
|
||||
tm_format.push_back(' ');
|
||||
|
||||
const size_t MIN_SIZE = 10;
|
||||
filename_t buf;
|
||||
buf.resize(MIN_SIZE);
|
||||
for (;;)
|
||||
{
|
||||
size_t count = strftime(buf.data(), buf.size(), tm_format.c_str(), &now_tm);
|
||||
if (count != 0)
|
||||
{
|
||||
// Remove the extra space.
|
||||
buf.resize(count - 1);
|
||||
break;
|
||||
}
|
||||
buf.resize(buf.size() * 2);
|
||||
}
|
||||
|
||||
return buf;
|
||||
#if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES)
|
||||
std::wstringstream stream;
|
||||
#else
|
||||
// generate fmt datetime format string, e.g. {:%Y-%m-%d}.
|
||||
filename_t fmt_filename = fmt::format(SPDLOG_FMT_STRING(SPDLOG_FILENAME_T("{{:{}}}")), filename);
|
||||
|
||||
// MSVC doesn't allow fmt::runtime(..) with wchar, with fmtlib versions < 9.1.x
|
||||
# if defined(_MSC_VER) && defined(SPDLOG_WCHAR_FILENAMES) && FMT_VERSION < 90101
|
||||
return fmt::format(fmt_filename, now_tm);
|
||||
# else
|
||||
return fmt::format(SPDLOG_FMT_RUNTIME(fmt_filename), now_tm);
|
||||
# endif
|
||||
|
||||
std::stringstream stream;
|
||||
#endif
|
||||
stream << std::put_time(&now_tm, file_path.c_str());
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
private:
|
||||
#if defined __GNUC__
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wformat-nonliteral"
|
||||
#endif
|
||||
|
||||
static size_t strftime(char *str, size_t count, const char *format, const std::tm *time)
|
||||
{
|
||||
return std::strftime(str, count, format, time);
|
||||
}
|
||||
|
||||
static size_t strftime(wchar_t *str, size_t count, const wchar_t *format, const std::tm *time)
|
||||
{
|
||||
return std::wcsftime(str, count, format, time);
|
||||
}
|
||||
|
||||
#if defined(__GNUC__)
|
||||
# pragma GCC diagnostic pop
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
|
8
r5dev/thirdparty/spdlog/sinks/dist_sink.h
vendored
8
r5dev/thirdparty/spdlog/sinks/dist_sink.h
vendored
@ -31,16 +31,16 @@ public:
|
||||
dist_sink(const dist_sink &) = delete;
|
||||
dist_sink &operator=(const dist_sink &) = delete;
|
||||
|
||||
void add_sink(std::shared_ptr<sink> sink)
|
||||
void add_sink(std::shared_ptr<sink> sub_sink)
|
||||
{
|
||||
std::lock_guard<Mutex> lock(base_sink<Mutex>::mutex_);
|
||||
sinks_.push_back(sink);
|
||||
sinks_.push_back(sub_sink);
|
||||
}
|
||||
|
||||
void remove_sink(std::shared_ptr<sink> sink)
|
||||
void remove_sink(std::shared_ptr<sink> sub_sink)
|
||||
{
|
||||
std::lock_guard<Mutex> lock(base_sink<Mutex>::mutex_);
|
||||
sinks_.erase(std::remove(sinks_.begin(), sinks_.end(), sink), sinks_.end());
|
||||
sinks_.erase(std::remove(sinks_.begin(), sinks_.end(), sub_sink), sinks_.end());
|
||||
}
|
||||
|
||||
void set_sinks(std::vector<std::shared_ptr<sink>> sinks)
|
||||
|
@ -20,7 +20,7 @@
|
||||
// #include <spdlog/sinks/dup_filter_sink.h>
|
||||
//
|
||||
// int main() {
|
||||
// auto dup_filter = std::make_shared<dup_filter_sink_st>(std::chrono::seconds(5));
|
||||
// auto dup_filter = std::make_shared<dup_filter_sink_st>(std::chrono::seconds(5), level::info);
|
||||
// dup_filter->add_sink(std::make_shared<stdout_color_sink_mt>());
|
||||
// spdlog::logger l("logger", dup_filter);
|
||||
// l.info("Hello");
|
||||
@ -41,8 +41,9 @@ class dup_filter_sink : public dist_sink<Mutex>
|
||||
{
|
||||
public:
|
||||
template<class Rep, class Period>
|
||||
explicit dup_filter_sink(std::chrono::duration<Rep, Period> max_skip_duration)
|
||||
explicit dup_filter_sink(std::chrono::duration<Rep, Period> max_skip_duration, level::level_enum notification_level = level::info)
|
||||
: max_skip_duration_{max_skip_duration}
|
||||
, log_level_{notification_level}
|
||||
{}
|
||||
|
||||
protected:
|
||||
@ -50,6 +51,7 @@ protected:
|
||||
log_clock::time_point last_msg_time_;
|
||||
std::string last_msg_payload_;
|
||||
size_t skip_counter_ = 0;
|
||||
level::level_enum log_level_;
|
||||
|
||||
void sink_it_(const details::log_msg &msg) override
|
||||
{
|
||||
@ -67,7 +69,7 @@ protected:
|
||||
auto msg_size = ::snprintf(buf, sizeof(buf), "Skipped %u duplicate messages..", static_cast<unsigned>(skip_counter_));
|
||||
if (msg_size > 0 && static_cast<size_t>(msg_size) < sizeof(buf))
|
||||
{
|
||||
details::log_msg skipped_msg{msg.logger_name, level::info, string_view_t{buf, static_cast<size_t>(msg_size)}};
|
||||
details::log_msg skipped_msg{msg.source, msg.logger_name, log_level_, string_view_t{buf, static_cast<size_t>(msg_size)}};
|
||||
dist_sink<Mutex>::sink_it_(skipped_msg);
|
||||
}
|
||||
}
|
||||
|
133
r5dev/thirdparty/spdlog/sinks/kafka_sink.h
vendored
Normal file
133
r5dev/thirdparty/spdlog/sinks/kafka_sink.h
vendored
Normal file
@ -0,0 +1,133 @@
|
||||
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
|
||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||
|
||||
#pragma once
|
||||
|
||||
//
|
||||
// Custom sink for kafka
|
||||
// Building and using requires librdkafka library.
|
||||
// For building librdkafka library check the url below
|
||||
// https://github.com/confluentinc/librdkafka
|
||||
//
|
||||
|
||||
#include <spdlog/common.h>
|
||||
#include "spdlog/details/log_msg.h"
|
||||
#include "spdlog/sinks/base_sink.h"
|
||||
#include "spdlog/details/synchronous_factory.h"
|
||||
#include "spdlog/details/null_mutex.h"
|
||||
#include "spdlog/async.h"
|
||||
#include <mutex>
|
||||
|
||||
// kafka header
|
||||
#include <librdkafka/rdkafkacpp.h>
|
||||
|
||||
namespace spdlog {
|
||||
namespace sinks {
|
||||
|
||||
struct kafka_sink_config
|
||||
{
|
||||
std::string server_addr;
|
||||
std::string produce_topic;
|
||||
int32_t flush_timeout_ms = 1000;
|
||||
|
||||
kafka_sink_config(std::string addr, std::string topic, int flush_timeout_ms = 1000)
|
||||
: server_addr{std::move(addr)}
|
||||
, produce_topic{std::move(topic)}
|
||||
, flush_timeout_ms(flush_timeout_ms)
|
||||
{}
|
||||
};
|
||||
|
||||
template<typename Mutex>
|
||||
class kafka_sink : public base_sink<Mutex>
|
||||
{
|
||||
public:
|
||||
kafka_sink(kafka_sink_config config)
|
||||
: config_{std::move(config)}
|
||||
{
|
||||
try
|
||||
{
|
||||
std::string errstr;
|
||||
conf_.reset(RdKafka::Conf::create(RdKafka::Conf::CONF_GLOBAL));
|
||||
RdKafka::Conf::ConfResult confRes = conf_->set("bootstrap.servers", config_.server_addr, errstr);
|
||||
if (confRes != RdKafka::Conf::CONF_OK)
|
||||
{
|
||||
throw_spdlog_ex(fmt_lib::format("conf set bootstrap.servers failed err:{}", errstr));
|
||||
}
|
||||
|
||||
tconf_.reset(RdKafka::Conf::create(RdKafka::Conf::CONF_TOPIC));
|
||||
if (tconf_ == nullptr)
|
||||
{
|
||||
throw_spdlog_ex(fmt_lib::format("create topic config failed"));
|
||||
}
|
||||
|
||||
producer_.reset(RdKafka::Producer::create(conf_.get(), errstr));
|
||||
if (producer_ == nullptr)
|
||||
{
|
||||
throw_spdlog_ex(fmt_lib::format("create producer failed err:{}", errstr));
|
||||
}
|
||||
topic_.reset(RdKafka::Topic::create(producer_.get(), config_.produce_topic, tconf_.get(), errstr));
|
||||
if (topic_ == nullptr)
|
||||
{
|
||||
throw_spdlog_ex(fmt_lib::format("create topic failed err:{}", errstr));
|
||||
}
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
throw_spdlog_ex(fmt_lib::format("error create kafka instance: {}", e.what()));
|
||||
}
|
||||
}
|
||||
|
||||
~kafka_sink()
|
||||
{
|
||||
producer_->flush(config_.flush_timeout_ms);
|
||||
}
|
||||
|
||||
protected:
|
||||
void sink_it_(const details::log_msg &msg) override
|
||||
{
|
||||
producer_->produce(topic_.get(), 0, RdKafka::Producer::RK_MSG_COPY, (void *)msg.payload.data(), msg.payload.size(), NULL, NULL);
|
||||
}
|
||||
|
||||
void flush_() override
|
||||
{
|
||||
producer_->flush(config_.flush_timeout_ms);
|
||||
}
|
||||
|
||||
private:
|
||||
kafka_sink_config config_;
|
||||
std::unique_ptr<RdKafka::Producer> producer_ = nullptr;
|
||||
std::unique_ptr<RdKafka::Conf> conf_ = nullptr;
|
||||
std::unique_ptr<RdKafka::Conf> tconf_ = nullptr;
|
||||
std::unique_ptr<RdKafka::Topic> topic_ = nullptr;
|
||||
};
|
||||
|
||||
using kafka_sink_mt = kafka_sink<std::mutex>;
|
||||
using kafka_sink_st = kafka_sink<spdlog::details::null_mutex>;
|
||||
|
||||
} // namespace sinks
|
||||
|
||||
template<typename Factory = spdlog::synchronous_factory>
|
||||
inline std::shared_ptr<logger> kafka_logger_mt(const std::string &logger_name, spdlog::sinks::kafka_sink_config config)
|
||||
{
|
||||
return Factory::template create<sinks::kafka_sink_mt>(logger_name, config);
|
||||
}
|
||||
|
||||
template<typename Factory = spdlog::synchronous_factory>
|
||||
inline std::shared_ptr<logger> kafka_logger_st(const std::string &logger_name, spdlog::sinks::kafka_sink_config config)
|
||||
{
|
||||
return Factory::template create<sinks::kafka_sink_st>(logger_name, config);
|
||||
}
|
||||
|
||||
template<typename Factory = spdlog::async_factory>
|
||||
inline std::shared_ptr<spdlog::logger> kafka_logger_async_mt(std::string logger_name, spdlog::sinks::kafka_sink_config config)
|
||||
{
|
||||
return Factory::template create<sinks::kafka_sink_mt>(logger_name, config);
|
||||
}
|
||||
|
||||
template<typename Factory = spdlog::async_factory>
|
||||
inline std::shared_ptr<spdlog::logger> kafka_logger_async_st(std::string logger_name, spdlog::sinks::kafka_sink_config config)
|
||||
{
|
||||
return Factory::template create<sinks::kafka_sink_st>(logger_name, config);
|
||||
}
|
||||
|
||||
} // namespace spdlog
|
24
r5dev/thirdparty/spdlog/sinks/msvc_sink.h
vendored
24
r5dev/thirdparty/spdlog/sinks/msvc_sink.h
vendored
@ -3,17 +3,23 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#if defined(_WIN32)
|
||||
|
||||
# include <spdlog/details/null_mutex.h>
|
||||
# if defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT)
|
||||
# include <spdlog/details/os.h>
|
||||
# endif
|
||||
# include <spdlog/sinks/base_sink.h>
|
||||
|
||||
# include <mutex>
|
||||
# include <string>
|
||||
|
||||
// Avoid including windows.h (https://stackoverflow.com/a/30741042)
|
||||
# if defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT)
|
||||
extern "C" __declspec(dllimport) void __stdcall OutputDebugStringW(const wchar_t *lpOutputString);
|
||||
# else
|
||||
extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA(const char *lpOutputString);
|
||||
# endif
|
||||
extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent();
|
||||
|
||||
namespace spdlog {
|
||||
@ -26,25 +32,31 @@ class msvc_sink : public base_sink<Mutex>
|
||||
{
|
||||
public:
|
||||
msvc_sink() = default;
|
||||
msvc_sink(bool check_ebugger_present)
|
||||
: check_debbugger_present_{check_ebugger_present} {};
|
||||
msvc_sink(bool check_debugger_present)
|
||||
: check_debugger_present_{check_debugger_present} {};
|
||||
|
||||
protected:
|
||||
void sink_it_(const details::log_msg &msg) override
|
||||
{
|
||||
if (check_debbugger_present_ && !IsDebuggerPresent())
|
||||
if (check_debugger_present_ && !IsDebuggerPresent())
|
||||
{
|
||||
return;
|
||||
}
|
||||
memory_buf_t formatted;
|
||||
base_sink<Mutex>::formatter_->format(msg, formatted);
|
||||
formatted.push_back('\0'); // add a null terminator for OutputDebugStringA
|
||||
formatted.push_back('\0'); // add a null terminator for OutputDebugString
|
||||
# if defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT)
|
||||
wmemory_buf_t wformatted;
|
||||
details::os::utf8_to_wstrbuf(string_view_t(formatted.data(), formatted.size()), wformatted);
|
||||
OutputDebugStringW(wformatted.data());
|
||||
# else
|
||||
OutputDebugStringA(formatted.data());
|
||||
# endif
|
||||
}
|
||||
|
||||
void flush_() override {}
|
||||
|
||||
bool check_debbugger_present_ = true;
|
||||
bool check_debugger_present_ = true;
|
||||
};
|
||||
|
||||
using msvc_sink_mt = msvc_sink<std::mutex>;
|
||||
|
202
r5dev/thirdparty/spdlog/sinks/qt_sinks.h
vendored
202
r5dev/thirdparty/spdlog/sinks/qt_sinks.h
vendored
@ -7,11 +7,16 @@
|
||||
// Custom sink for QPlainTextEdit or QTextEdit and its childs(QTextBrowser...
|
||||
// etc) Building and using requires Qt library.
|
||||
//
|
||||
// Warning: the qt_sink won't be notified if the target widget is destroyed.
|
||||
// If the widget's lifetime can be shorter than the logger's one, you should provide some permanent QObject,
|
||||
// and then use a standard signal/slot.
|
||||
//
|
||||
|
||||
#include "spdlog/common.h"
|
||||
#include "spdlog/details/log_msg.h"
|
||||
#include "spdlog/details/synchronous_factory.h"
|
||||
#include "spdlog/sinks/base_sink.h"
|
||||
#include <array>
|
||||
|
||||
#include <QTextEdit>
|
||||
#include <QPlainTextEdit>
|
||||
@ -25,10 +30,14 @@ template<typename Mutex>
|
||||
class qt_sink : public base_sink<Mutex>
|
||||
{
|
||||
public:
|
||||
qt_sink(QObject *qt_object, const std::string &meta_method)
|
||||
qt_sink(QObject *qt_object, std::string meta_method)
|
||||
: qt_object_(qt_object)
|
||||
, meta_method_(std::move(meta_method))
|
||||
{
|
||||
qt_object_ = qt_object;
|
||||
meta_method_ = meta_method;
|
||||
if (!qt_object_)
|
||||
{
|
||||
throw_spdlog_ex("qt_sink: qt_object is null");
|
||||
}
|
||||
}
|
||||
|
||||
~qt_sink()
|
||||
@ -41,7 +50,7 @@ protected:
|
||||
{
|
||||
memory_buf_t formatted;
|
||||
base_sink<Mutex>::formatter_->format(msg, formatted);
|
||||
string_view_t str = string_view_t(formatted.data(), formatted.size());
|
||||
const string_view_t str = string_view_t(formatted.data(), formatted.size());
|
||||
QMetaObject::invokeMethod(qt_object_, meta_method_.c_str(), Qt::AutoConnection,
|
||||
Q_ARG(QString, QString::fromUtf8(str.data(), static_cast<int>(str.size())).trimmed()));
|
||||
}
|
||||
@ -53,15 +62,181 @@ private:
|
||||
std::string meta_method_;
|
||||
};
|
||||
|
||||
// QT color sink to QTextEdit.
|
||||
// Color location is determined by the sink log pattern like in the rest of spdlog sinks.
|
||||
// Colors can be modified if needed using sink->set_color(level, qtTextCharFormat).
|
||||
// max_lines is the maximum number of lines that the sink will hold before removing the oldest lines.
|
||||
// Note: Only ascii (latin1) is supported by this sink.
|
||||
template<typename Mutex>
|
||||
class qt_color_sink : public base_sink<Mutex>
|
||||
{
|
||||
public:
|
||||
qt_color_sink(QTextEdit *qt_text_edit, int max_lines)
|
||||
: qt_text_edit_(qt_text_edit)
|
||||
, max_lines_(max_lines)
|
||||
{
|
||||
if (!qt_text_edit_)
|
||||
{
|
||||
throw_spdlog_ex("qt_color_text_sink: text_edit is null");
|
||||
}
|
||||
|
||||
default_color_ = qt_text_edit_->currentCharFormat();
|
||||
// set colors
|
||||
QTextCharFormat format;
|
||||
// trace
|
||||
format.setForeground(Qt::gray);
|
||||
colors_.at(level::trace) = format;
|
||||
// debug
|
||||
format.setForeground(Qt::cyan);
|
||||
colors_.at(level::debug) = format;
|
||||
// info
|
||||
format.setForeground(Qt::green);
|
||||
colors_.at(level::info) = format;
|
||||
// warn
|
||||
format.setForeground(Qt::yellow);
|
||||
colors_.at(level::warn) = format;
|
||||
// err
|
||||
format.setForeground(Qt::red);
|
||||
colors_.at(level::err) = format;
|
||||
// critical
|
||||
format.setForeground(Qt::white);
|
||||
format.setBackground(Qt::red);
|
||||
colors_.at(level::critical) = format;
|
||||
}
|
||||
|
||||
~qt_color_sink()
|
||||
{
|
||||
flush_();
|
||||
}
|
||||
|
||||
void set_default_color(QTextCharFormat format)
|
||||
{
|
||||
// std::lock_guard<Mutex> lock(base_sink<Mutex>::mutex_);
|
||||
default_color_ = format;
|
||||
}
|
||||
|
||||
void set_level_color(level::level_enum color_level, QTextCharFormat format)
|
||||
{
|
||||
// std::lock_guard<Mutex> lock(base_sink<Mutex>::mutex_);
|
||||
colors_.at(static_cast<size_t>(color_level)) = format;
|
||||
}
|
||||
|
||||
QTextCharFormat &get_level_color(level::level_enum color_level)
|
||||
{
|
||||
std::lock_guard<Mutex> lock(base_sink<Mutex>::mutex_);
|
||||
return colors_.at(static_cast<size_t>(color_level));
|
||||
}
|
||||
|
||||
QTextCharFormat &get_default_color()
|
||||
{
|
||||
std::lock_guard<Mutex> lock(base_sink<Mutex>::mutex_);
|
||||
return default_color_;
|
||||
}
|
||||
|
||||
protected:
|
||||
struct invoke_params
|
||||
{
|
||||
invoke_params(int max_lines, QTextEdit *q_text_edit, QString payload, QTextCharFormat default_color, QTextCharFormat level_color,
|
||||
int color_range_start, int color_range_end)
|
||||
: max_lines(max_lines)
|
||||
, q_text_edit(q_text_edit)
|
||||
, payload(std::move(payload))
|
||||
, default_color(default_color)
|
||||
, level_color(level_color)
|
||||
, color_range_start(color_range_start)
|
||||
, color_range_end(color_range_end)
|
||||
{}
|
||||
int max_lines;
|
||||
QTextEdit *q_text_edit;
|
||||
QString payload;
|
||||
QTextCharFormat default_color;
|
||||
QTextCharFormat level_color;
|
||||
int color_range_start;
|
||||
int color_range_end;
|
||||
};
|
||||
|
||||
void sink_it_(const details::log_msg &msg) override
|
||||
{
|
||||
memory_buf_t formatted;
|
||||
base_sink<Mutex>::formatter_->format(msg, formatted);
|
||||
|
||||
const string_view_t str = string_view_t(formatted.data(), formatted.size());
|
||||
// apply the color to the color range in the formatted message.
|
||||
auto payload = QString::fromLatin1(str.data(), static_cast<int>(str.size()));
|
||||
|
||||
invoke_params params{max_lines_, // max lines
|
||||
qt_text_edit_, // text edit to append to
|
||||
std::move(payload), // text to append
|
||||
default_color_, // default color
|
||||
colors_.at(msg.level), // color to apply
|
||||
static_cast<int>(msg.color_range_start), // color range start
|
||||
static_cast<int>(msg.color_range_end)}; // color range end
|
||||
|
||||
QMetaObject::invokeMethod(
|
||||
qt_text_edit_, [params]() { invoke_method_(params); }, Qt::AutoConnection);
|
||||
}
|
||||
|
||||
void flush_() override {}
|
||||
|
||||
// Add colored text to the text edit widget. This method is invoked in the GUI thread.
|
||||
// It is a static method to ensure that it is handled correctly even if the sink is destroyed prematurely
|
||||
// before it is invoked.
|
||||
|
||||
static void invoke_method_(invoke_params params)
|
||||
{
|
||||
auto *document = params.q_text_edit->document();
|
||||
QTextCursor cursor(document);
|
||||
|
||||
// remove first blocks if number of blocks exceeds max_lines
|
||||
while (document->blockCount() > params.max_lines)
|
||||
{
|
||||
cursor.select(QTextCursor::BlockUnderCursor);
|
||||
cursor.removeSelectedText();
|
||||
cursor.deleteChar(); // delete the newline after the block
|
||||
}
|
||||
|
||||
cursor.movePosition(QTextCursor::End);
|
||||
cursor.setCharFormat(params.default_color);
|
||||
|
||||
// if color range not specified or not not valid, just append the text with default color
|
||||
if (params.color_range_end <= params.color_range_start)
|
||||
{
|
||||
cursor.insertText(params.payload);
|
||||
return;
|
||||
}
|
||||
|
||||
// insert the text before the color range
|
||||
cursor.insertText(params.payload.left(params.color_range_start));
|
||||
|
||||
// insert the colorized text
|
||||
cursor.setCharFormat(params.level_color);
|
||||
cursor.insertText(params.payload.mid(params.color_range_start, params.color_range_end - params.color_range_start));
|
||||
|
||||
// insert the text after the color range with default format
|
||||
cursor.setCharFormat(params.default_color);
|
||||
cursor.insertText(params.payload.mid(params.color_range_end));
|
||||
}
|
||||
|
||||
QTextEdit *qt_text_edit_;
|
||||
int max_lines_;
|
||||
QTextCharFormat default_color_;
|
||||
std::array<QTextCharFormat, level::n_levels> colors_;
|
||||
};
|
||||
|
||||
#include "spdlog/details/null_mutex.h"
|
||||
#include <mutex>
|
||||
|
||||
using qt_sink_mt = qt_sink<std::mutex>;
|
||||
using qt_sink_st = qt_sink<spdlog::details::null_mutex>;
|
||||
using qt_sink_st = qt_sink<details::null_mutex>;
|
||||
using qt_color_sink_mt = qt_color_sink<std::mutex>;
|
||||
using qt_color_sink_st = qt_color_sink<details::null_mutex>;
|
||||
} // namespace sinks
|
||||
|
||||
//
|
||||
// Factory functions
|
||||
//
|
||||
|
||||
// log to QTextEdit
|
||||
template<typename Factory = spdlog::synchronous_factory>
|
||||
inline std::shared_ptr<logger> qt_logger_mt(const std::string &logger_name, QTextEdit *qt_object, const std::string &meta_method = "append")
|
||||
{
|
||||
@ -74,6 +249,7 @@ inline std::shared_ptr<logger> qt_logger_st(const std::string &logger_name, QTex
|
||||
return Factory::template create<sinks::qt_sink_st>(logger_name, qt_object, meta_method);
|
||||
}
|
||||
|
||||
// log to QPlainTextEdit
|
||||
template<typename Factory = spdlog::synchronous_factory>
|
||||
inline std::shared_ptr<logger> qt_logger_mt(
|
||||
const std::string &logger_name, QPlainTextEdit *qt_object, const std::string &meta_method = "appendPlainText")
|
||||
@ -87,7 +263,7 @@ inline std::shared_ptr<logger> qt_logger_st(
|
||||
{
|
||||
return Factory::template create<sinks::qt_sink_st>(logger_name, qt_object, meta_method);
|
||||
}
|
||||
|
||||
// log to QObject
|
||||
template<typename Factory = spdlog::synchronous_factory>
|
||||
inline std::shared_ptr<logger> qt_logger_mt(const std::string &logger_name, QObject *qt_object, const std::string &meta_method)
|
||||
{
|
||||
@ -99,4 +275,18 @@ inline std::shared_ptr<logger> qt_logger_st(const std::string &logger_name, QObj
|
||||
{
|
||||
return Factory::template create<sinks::qt_sink_st>(logger_name, qt_object, meta_method);
|
||||
}
|
||||
|
||||
// log to QTextEdit with colorize output
|
||||
template<typename Factory = spdlog::synchronous_factory>
|
||||
inline std::shared_ptr<logger> qt_color_logger_mt(const std::string &logger_name, QTextEdit *qt_text_edit, int max_lines)
|
||||
{
|
||||
return Factory::template create<sinks::qt_color_sink_mt>(logger_name, qt_text_edit, max_lines);
|
||||
}
|
||||
|
||||
template<typename Factory = spdlog::synchronous_factory>
|
||||
inline std::shared_ptr<logger> qt_color_logger_st(const std::string &logger_name, QTextEdit *qt_text_edit, int max_lines)
|
||||
{
|
||||
return Factory::template create<sinks::qt_color_sink_st>(logger_name, qt_text_edit, max_lines);
|
||||
}
|
||||
|
||||
} // namespace spdlog
|
||||
|
@ -50,7 +50,7 @@ public:
|
||||
{
|
||||
memory_buf_t formatted;
|
||||
base_sink<Mutex>::formatter_->format(q_.at(i), formatted);
|
||||
ret.push_back(std::move(SPDLOG_BUF_TO_STRING(formatted)));
|
||||
ret.push_back(SPDLOG_BUF_TO_STRING(formatted));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -60,7 +60,6 @@ SPDLOG_INLINE void stdout_sink_base<ConsoleMutex>::log(const details::log_msg &m
|
||||
std::lock_guard<mutex_t> lock(mutex_);
|
||||
memory_buf_t formatted;
|
||||
formatter_->format(msg, formatted);
|
||||
::fflush(file_); // flush in case there is something in this file_ already
|
||||
auto size = static_cast<DWORD>(formatted.size());
|
||||
DWORD bytes_written = 0;
|
||||
bool ok = ::WriteFile(handle_, formatted.data(), size, &bytes_written, nullptr) != 0;
|
||||
@ -73,8 +72,8 @@ SPDLOG_INLINE void stdout_sink_base<ConsoleMutex>::log(const details::log_msg &m
|
||||
memory_buf_t formatted;
|
||||
formatter_->format(msg, formatted);
|
||||
::fwrite(formatted.data(), sizeof(char), formatted.size(), file_);
|
||||
#endif // WIN32
|
||||
::fflush(file_); // flush every line to terminal
|
||||
#endif // WIN32
|
||||
}
|
||||
|
||||
template<typename ConsoleMutex>
|
||||
|
7
r5dev/thirdparty/spdlog/sinks/systemd_sink.h
vendored
7
r5dev/thirdparty/spdlog/sinks/systemd_sink.h
vendored
@ -4,6 +4,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <spdlog/sinks/base_sink.h>
|
||||
#include <spdlog/details/os.h>
|
||||
#include <spdlog/details/null_mutex.h>
|
||||
#include <spdlog/details/synchronous_factory.h>
|
||||
|
||||
@ -75,11 +76,17 @@ protected:
|
||||
{
|
||||
// Note: function call inside '()' to avoid macro expansion
|
||||
err = (sd_journal_send)("MESSAGE=%.*s", static_cast<int>(length), payload.data(), "PRIORITY=%d", syslog_level(msg.level),
|
||||
#ifndef SPDLOG_NO_THREAD_ID
|
||||
"TID=%zu", details::os::thread_id(),
|
||||
#endif
|
||||
"SYSLOG_IDENTIFIER=%.*s", static_cast<int>(syslog_identifier.size()), syslog_identifier.data(), nullptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
err = (sd_journal_send)("MESSAGE=%.*s", static_cast<int>(length), payload.data(), "PRIORITY=%d", syslog_level(msg.level),
|
||||
#ifndef SPDLOG_NO_THREAD_ID
|
||||
"TID=%zu", details::os::thread_id(),
|
||||
#endif
|
||||
"SYSLOG_IDENTIFIER=%.*s", static_cast<int>(syslog_identifier.size()), syslog_identifier.data(), "CODE_FILE=%s",
|
||||
msg.source.filename, "CODE_LINE=%d", msg.source.line, "CODE_FUNC=%s", msg.source.funcname, nullptr);
|
||||
}
|
||||
|
@ -210,7 +210,7 @@ private:
|
||||
HANDLE hEventLog_{NULL};
|
||||
internal::sid_t current_user_sid_;
|
||||
std::string source_;
|
||||
WORD event_id_;
|
||||
DWORD event_id_;
|
||||
|
||||
HANDLE event_log_handle()
|
||||
{
|
||||
@ -241,12 +241,12 @@ protected:
|
||||
details::os::utf8_to_wstrbuf(string_view_t(formatted.data(), formatted.size()), buf);
|
||||
|
||||
LPCWSTR lp_wstr = buf.data();
|
||||
succeeded = static_cast<bool>(::ReportEventW(event_log_handle(), eventlog::get_event_type(msg), eventlog::get_event_category(msg), event_id_,
|
||||
current_user_sid_.as_sid(), 1, 0, &lp_wstr, nullptr));
|
||||
succeeded = static_cast<bool>(::ReportEventW(event_log_handle(), eventlog::get_event_type(msg), eventlog::get_event_category(msg),
|
||||
event_id_, current_user_sid_.as_sid(), 1, 0, &lp_wstr, nullptr));
|
||||
#else
|
||||
LPCSTR lp_str = formatted.data();
|
||||
succeeded = static_cast<bool>(::ReportEventA(event_log_handle(), eventlog::get_event_type(msg), eventlog::get_event_category(msg), event_id_,
|
||||
current_user_sid_.as_sid(), 1, 0, &lp_str, nullptr));
|
||||
succeeded = static_cast<bool>(::ReportEventA(event_log_handle(), eventlog::get_event_type(msg), eventlog::get_event_category(msg),
|
||||
event_id_, current_user_sid_.as_sid(), 1, 0, &lp_str, nullptr));
|
||||
#endif
|
||||
|
||||
if (!succeeded)
|
||||
@ -258,7 +258,7 @@ protected:
|
||||
void flush_() override {}
|
||||
|
||||
public:
|
||||
win_eventlog_sink(std::string const &source, WORD event_id = 1000 /* according to mscoree.dll */)
|
||||
win_eventlog_sink(std::string const &source, DWORD event_id = 1000 /* according to mscoree.dll */)
|
||||
: source_(source)
|
||||
, event_id_(event_id)
|
||||
{
|
||||
|
5
r5dev/thirdparty/spdlog/spdlog-inl.h
vendored
5
r5dev/thirdparty/spdlog/spdlog-inl.h
vendored
@ -117,4 +117,9 @@ SPDLOG_INLINE void set_default_logger(std::shared_ptr<spdlog::logger> default_lo
|
||||
details::registry::instance().set_default_logger(std::move(default_logger));
|
||||
}
|
||||
|
||||
SPDLOG_INLINE void apply_logger_env_levels(std::shared_ptr<logger> logger)
|
||||
{
|
||||
details::registry::instance().apply_logger_env_levels(std::move(logger));
|
||||
}
|
||||
|
||||
} // namespace spdlog
|
||||
|
43
r5dev/thirdparty/spdlog/spdlog.h
vendored
43
r5dev/thirdparty/spdlog/spdlog.h
vendored
@ -31,7 +31,7 @@ using default_factory = synchronous_factory;
|
||||
// Example:
|
||||
// spdlog::create<daily_file_sink_st>("logger_name", "dailylog_filename", 11, 59);
|
||||
template<typename Sink, typename... SinkArgs>
|
||||
inline std::shared_ptr<spdlog::logger> create(std::string logger_name, SinkArgs &&... sink_args)
|
||||
inline std::shared_ptr<spdlog::logger> create(std::string logger_name, SinkArgs &&...sink_args)
|
||||
{
|
||||
return default_factory::create<Sink>(std::move(logger_name), std::forward<SinkArgs>(sink_args)...);
|
||||
}
|
||||
@ -131,50 +131,59 @@ SPDLOG_API spdlog::logger *default_logger_raw();
|
||||
|
||||
SPDLOG_API void set_default_logger(std::shared_ptr<spdlog::logger> default_logger);
|
||||
|
||||
// Initialize logger level based on environment configs.
|
||||
//
|
||||
// Useful for applying SPDLOG_LEVEL to manually created loggers.
|
||||
//
|
||||
// Example:
|
||||
// auto mylogger = std::make_shared<spdlog::logger>("mylogger", ...);
|
||||
// spdlog::apply_logger_env_levels(mylogger);
|
||||
SPDLOG_API void apply_logger_env_levels(std::shared_ptr<logger> logger);
|
||||
|
||||
template<typename... Args>
|
||||
inline void log(source_loc source, level::level_enum lvl, format_string_t<Args...> fmt, Args &&... args)
|
||||
inline void log(source_loc source, level::level_enum lvl, format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->log(source, lvl, fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void log(level::level_enum lvl, format_string_t<Args...> fmt, Args &&... args)
|
||||
inline void log(level::level_enum lvl, format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->log(source_loc{}, lvl, fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void trace(format_string_t<Args...> fmt, Args &&... args)
|
||||
inline void trace(format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->trace(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void debug(format_string_t<Args...> fmt, Args &&... args)
|
||||
inline void debug(format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->debug(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void info(format_string_t<Args...> fmt, Args &&... args)
|
||||
inline void info(format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->info(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void warn(format_string_t<Args...> fmt, Args &&... args)
|
||||
inline void warn(format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->warn(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void error(format_string_t<Args...> fmt, Args &&... args)
|
||||
inline void error(format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->error(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void critical(format_string_t<Args...> fmt, Args &&... args)
|
||||
inline void critical(format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->critical(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
@ -193,49 +202,49 @@ inline void log(level::level_enum lvl, const T &msg)
|
||||
|
||||
#ifdef SPDLOG_WCHAR_TO_UTF8_SUPPORT
|
||||
template<typename... Args>
|
||||
inline void log(source_loc source, level::level_enum lvl, wformat_string_t<Args...> fmt, Args &&... args)
|
||||
inline void log(source_loc source, level::level_enum lvl, wformat_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->log(source, lvl, fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void log(level::level_enum lvl, wformat_string_t<Args...> fmt, Args &&... args)
|
||||
inline void log(level::level_enum lvl, wformat_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->log(source_loc{}, lvl, fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void trace(wformat_string_t<Args...> fmt, Args &&... args)
|
||||
inline void trace(wformat_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->trace(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void debug(wformat_string_t<Args...> fmt, Args &&... args)
|
||||
inline void debug(wformat_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->debug(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void info(wformat_string_t<Args...> fmt, Args &&... args)
|
||||
inline void info(wformat_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->info(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void warn(wformat_string_t<Args...> fmt, Args &&... args)
|
||||
inline void warn(wformat_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->warn(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void error(wformat_string_t<Args...> fmt, Args &&... args)
|
||||
inline void error(wformat_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->error(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void critical(wformat_string_t<Args...> fmt, Args &&... args)
|
||||
inline void critical(wformat_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->critical(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
2
r5dev/thirdparty/spdlog/stopwatch.h
vendored
2
r5dev/thirdparty/spdlog/stopwatch.h
vendored
@ -61,7 +61,7 @@ template<>
|
||||
struct formatter<spdlog::stopwatch> : formatter<double>
|
||||
{
|
||||
template<typename FormatContext>
|
||||
auto format(const spdlog::stopwatch &sw, FormatContext &ctx) -> decltype(ctx.out())
|
||||
auto format(const spdlog::stopwatch &sw, FormatContext &ctx) const -> decltype(ctx.out())
|
||||
{
|
||||
return formatter<double>::format(sw.elapsed().count(), ctx);
|
||||
}
|
||||
|
3
r5dev/thirdparty/spdlog/tweakme.h
vendored
3
r5dev/thirdparty/spdlog/tweakme.h
vendored
@ -82,8 +82,7 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Uncomment to use C++20 std::format instead of fmt. This removes compile
|
||||
// time checking of format strings, but doesn't depend on the fmt library.
|
||||
// Uncomment to use C++20 std::format instead of fmt.
|
||||
//
|
||||
// #define SPDLOG_USE_STD_FORMAT
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
2
r5dev/thirdparty/spdlog/version.h
vendored
2
r5dev/thirdparty/spdlog/version.h
vendored
@ -4,7 +4,7 @@
|
||||
#pragma once
|
||||
|
||||
#define SPDLOG_VER_MAJOR 1
|
||||
#define SPDLOG_VER_MINOR 11
|
||||
#define SPDLOG_VER_MINOR 12
|
||||
#define SPDLOG_VER_PATCH 0
|
||||
|
||||
#define SPDLOG_VERSION (SPDLOG_VER_MAJOR * 10000 + SPDLOG_VER_MINOR * 100 + SPDLOG_VER_PATCH)
|
||||
|
Loading…
x
Reference in New Issue
Block a user