mirror of
https://github.com/gabime/spdlog.git
synced 2024-11-15 08:25:43 +08:00
update clang format again
This commit is contained in:
parent
251c856a12
commit
0a53eafe18
@ -43,8 +43,7 @@ int count_lines(const char *filename) {
|
|||||||
auto *infile = fopen(filename, "r");
|
auto *infile = fopen(filename, "r");
|
||||||
int ch;
|
int ch;
|
||||||
while (EOF != (ch = getc(infile))) {
|
while (EOF != (ch = getc(infile))) {
|
||||||
if ('\n' == ch)
|
if ('\n' == ch) counter++;
|
||||||
counter++;
|
|
||||||
}
|
}
|
||||||
fclose(infile);
|
fclose(infile);
|
||||||
|
|
||||||
@ -67,7 +66,6 @@ void verify_file(const char *filename, int expected_count) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
int howmany = 1000000;
|
int howmany = 1000000;
|
||||||
int queue_size = std::min(howmany + 2, 8192);
|
int queue_size = std::min(howmany + 2, 8192);
|
||||||
int threads = 10;
|
int threads = 10;
|
||||||
@ -80,10 +78,8 @@ int main(int argc, char *argv[]) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc > 1)
|
if (argc > 1) howmany = atoi(argv[1]);
|
||||||
howmany = atoi(argv[1]);
|
if (argc > 2) threads = atoi(argv[2]);
|
||||||
if (argc > 2)
|
|
||||||
threads = atoi(argv[2]);
|
|
||||||
if (argc > 3) {
|
if (argc > 3) {
|
||||||
queue_size = atoi(argv[3]);
|
queue_size = atoi(argv[3]);
|
||||||
if (queue_size > 500000) {
|
if (queue_size > 500000) {
|
||||||
@ -92,8 +88,7 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc > 4)
|
if (argc > 4) iters = atoi(argv[4]);
|
||||||
iters = atoi(argv[4]);
|
|
||||||
|
|
||||||
auto slot_size = sizeof(spdlog::details::async_msg);
|
auto slot_size = sizeof(spdlog::details::async_msg);
|
||||||
spdlog::info("-------------------------------------------------");
|
spdlog::info("-------------------------------------------------");
|
||||||
|
@ -122,7 +122,6 @@ int main(int argc, char *argv[]) {
|
|||||||
int iters = 250000;
|
int iters = 250000;
|
||||||
size_t threads = 4;
|
size_t threads = 4;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
iters = std::stoi(argv[1]);
|
iters = std::stoi(argv[1]);
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,6 @@ void bench_formatters() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
spdlog::set_pattern("[%^%l%$] %v");
|
spdlog::set_pattern("[%^%l%$] %v");
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
spdlog::error("Usage: {} <pattern> (or \"all\" to bench all)", argv[0]);
|
spdlog::error("Usage: {} <pattern> (or \"all\" to bench all)", argv[0]);
|
||||||
|
@ -319,8 +319,9 @@ void android_example() {
|
|||||||
#include "spdlog/pattern_formatter.h"
|
#include "spdlog/pattern_formatter.h"
|
||||||
class my_formatter_flag : public spdlog::custom_flag_formatter {
|
class my_formatter_flag : public spdlog::custom_flag_formatter {
|
||||||
public:
|
public:
|
||||||
void
|
void format(const spdlog::details::log_msg &,
|
||||||
format(const spdlog::details::log_msg &, const std::tm &, spdlog::memory_buf_t &dest) override {
|
const std::tm &,
|
||||||
|
spdlog::memory_buf_t &dest) override {
|
||||||
std::string some_txt = "custom-flag";
|
std::string some_txt = "custom-flag";
|
||||||
dest.append(some_txt.data(), some_txt.data() + some_txt.size());
|
dest.append(some_txt.data(), some_txt.data() + some_txt.size());
|
||||||
}
|
}
|
||||||
@ -331,7 +332,6 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
void custom_flags_example() {
|
void custom_flags_example() {
|
||||||
|
|
||||||
using spdlog::details::make_unique; // for pre c++14
|
using spdlog::details::make_unique; // for pre c++14
|
||||||
auto formatter = make_unique<spdlog::pattern_formatter>();
|
auto formatter = make_unique<spdlog::pattern_formatter>();
|
||||||
formatter->add_flag<my_formatter_flag>('*').set_pattern("[%n] [%*] [%^%l%$] %v");
|
formatter->add_flag<my_formatter_flag>('*').set_pattern("[%n] [%*] [%^%l%$] %v");
|
||||||
|
@ -82,8 +82,9 @@ inline void init_thread_pool(size_t q_size,
|
|||||||
details::registry::instance().set_tp(std::move(tp));
|
details::registry::instance().set_tp(std::move(tp));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void init_thread_pool(size_t q_size,
|
||||||
init_thread_pool(size_t q_size, size_t thread_count, std::function<void()> on_thread_start) {
|
size_t thread_count,
|
||||||
|
std::function<void()> on_thread_start) {
|
||||||
init_thread_pool(q_size, thread_count, on_thread_start, [] {});
|
init_thread_pool(q_size, thread_count, on_thread_start, [] {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,24 +333,24 @@ namespace details {
|
|||||||
|
|
||||||
// to_string_view
|
// to_string_view
|
||||||
|
|
||||||
SPDLOG_CONSTEXPR_FUNC spdlog::string_view_t
|
SPDLOG_CONSTEXPR_FUNC spdlog::string_view_t to_string_view(const memory_buf_t &buf)
|
||||||
to_string_view(const memory_buf_t &buf) SPDLOG_NOEXCEPT {
|
SPDLOG_NOEXCEPT {
|
||||||
return spdlog::string_view_t{buf.data(), buf.size()};
|
return spdlog::string_view_t{buf.data(), buf.size()};
|
||||||
}
|
}
|
||||||
|
|
||||||
SPDLOG_CONSTEXPR_FUNC spdlog::string_view_t
|
SPDLOG_CONSTEXPR_FUNC spdlog::string_view_t to_string_view(spdlog::string_view_t str)
|
||||||
to_string_view(spdlog::string_view_t str) SPDLOG_NOEXCEPT {
|
SPDLOG_NOEXCEPT {
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(SPDLOG_WCHAR_FILENAMES) || defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT)
|
#if defined(SPDLOG_WCHAR_FILENAMES) || defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT)
|
||||||
SPDLOG_CONSTEXPR_FUNC spdlog::wstring_view_t
|
SPDLOG_CONSTEXPR_FUNC spdlog::wstring_view_t to_string_view(const wmemory_buf_t &buf)
|
||||||
to_string_view(const wmemory_buf_t &buf) SPDLOG_NOEXCEPT {
|
SPDLOG_NOEXCEPT {
|
||||||
return spdlog::wstring_view_t{buf.data(), buf.size()};
|
return spdlog::wstring_view_t{buf.data(), buf.size()};
|
||||||
}
|
}
|
||||||
|
|
||||||
SPDLOG_CONSTEXPR_FUNC spdlog::wstring_view_t
|
SPDLOG_CONSTEXPR_FUNC spdlog::wstring_view_t to_string_view(spdlog::wstring_view_t str)
|
||||||
to_string_view(spdlog::wstring_view_t str) SPDLOG_NOEXCEPT {
|
SPDLOG_NOEXCEPT {
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -362,8 +362,8 @@ inline fmt::basic_string_view<T> to_string_view(fmt::basic_format_string<T, Args
|
|||||||
}
|
}
|
||||||
#elif __cpp_lib_format >= 202207L
|
#elif __cpp_lib_format >= 202207L
|
||||||
template <typename T, typename... Args>
|
template <typename T, typename... Args>
|
||||||
SPDLOG_CONSTEXPR_FUNC std::basic_string_view<T>
|
SPDLOG_CONSTEXPR_FUNC std::basic_string_view<T> to_string_view(
|
||||||
to_string_view(std::basic_format_string<T, Args...> fmt) SPDLOG_NOEXCEPT {
|
std::basic_format_string<T, Args...> fmt) SPDLOG_NOEXCEPT {
|
||||||
return fmt.get();
|
return fmt.get();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -127,8 +127,8 @@ SPDLOG_INLINE const filename_t &file_helper::filename() const { return filename_
|
|||||||
// ".mylog" => (".mylog". "")
|
// ".mylog" => (".mylog". "")
|
||||||
// "my_folder/.mylog" => ("my_folder/.mylog", "")
|
// "my_folder/.mylog" => ("my_folder/.mylog", "")
|
||||||
// "my_folder/.mylog.txt" => ("my_folder/.mylog", ".txt")
|
// "my_folder/.mylog.txt" => ("my_folder/.mylog", ".txt")
|
||||||
SPDLOG_INLINE std::tuple<filename_t, filename_t>
|
SPDLOG_INLINE std::tuple<filename_t, filename_t> file_helper::split_by_extension(
|
||||||
file_helper::split_by_extension(const filename_t &fname) {
|
const filename_t &fname) {
|
||||||
auto ext_index = fname.rfind('.');
|
auto ext_index = fname.rfind('.');
|
||||||
|
|
||||||
// no valid extension found - return whole path and empty string as
|
// no valid extension found - return whole path and empty string as
|
||||||
|
@ -53,14 +53,10 @@ SPDLOG_CONSTEXPR_FUNC unsigned int count_digits_fallback(T n) {
|
|||||||
// Integer division is slow so do it for a group of four digits instead
|
// Integer division is slow so do it for a group of four digits instead
|
||||||
// of for every digit. The idea comes from the talk by Alexandrescu
|
// of for every digit. The idea comes from the talk by Alexandrescu
|
||||||
// "Three Optimization Tips for C++". See speed-test for a comparison.
|
// "Three Optimization Tips for C++". See speed-test for a comparison.
|
||||||
if (n < 10)
|
if (n < 10) return count;
|
||||||
return count;
|
if (n < 100) return count + 1;
|
||||||
if (n < 100)
|
if (n < 1000) return count + 2;
|
||||||
return count + 1;
|
if (n < 10000) return count + 3;
|
||||||
if (n < 1000)
|
|
||||||
return count + 2;
|
|
||||||
if (n < 10000)
|
|
||||||
return count + 3;
|
|
||||||
n /= 10000u;
|
n /= 10000u;
|
||||||
count += 4;
|
count += 4;
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,6 @@ namespace details {
|
|||||||
namespace os {
|
namespace os {
|
||||||
|
|
||||||
SPDLOG_INLINE spdlog::log_clock::time_point now() SPDLOG_NOEXCEPT {
|
SPDLOG_INLINE spdlog::log_clock::time_point now() SPDLOG_NOEXCEPT {
|
||||||
|
|
||||||
#if defined __linux__ && defined SPDLOG_CLOCK_COARSE
|
#if defined __linux__ && defined SPDLOG_CLOCK_COARSE
|
||||||
timespec ts;
|
timespec ts;
|
||||||
::clock_gettime(CLOCK_REALTIME_COARSE, &ts);
|
::clock_gettime(CLOCK_REALTIME_COARSE, &ts);
|
||||||
@ -87,7 +86,6 @@ SPDLOG_INLINE spdlog::log_clock::time_point now() SPDLOG_NOEXCEPT {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
SPDLOG_INLINE std::tm localtime(const std::time_t &time_tt) SPDLOG_NOEXCEPT {
|
SPDLOG_INLINE std::tm localtime(const std::time_t &time_tt) SPDLOG_NOEXCEPT {
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
std::tm tm;
|
std::tm tm;
|
||||||
::localtime_s(&tm, &time_tt);
|
::localtime_s(&tm, &time_tt);
|
||||||
@ -104,7 +102,6 @@ SPDLOG_INLINE std::tm localtime() SPDLOG_NOEXCEPT {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SPDLOG_INLINE std::tm gmtime(const std::time_t &time_tt) SPDLOG_NOEXCEPT {
|
SPDLOG_INLINE std::tm gmtime(const std::time_t &time_tt) SPDLOG_NOEXCEPT {
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
std::tm tm;
|
std::tm tm;
|
||||||
::gmtime_s(&tm, &time_tt);
|
::gmtime_s(&tm, &time_tt);
|
||||||
@ -249,7 +246,6 @@ SPDLOG_INLINE size_t filesize(FILE *f) {
|
|||||||
|
|
||||||
// Return utc offset in minutes or throw spdlog_ex on failure
|
// Return utc offset in minutes or throw spdlog_ex on failure
|
||||||
SPDLOG_INLINE int utc_minutes_offset(const std::tm &tm) {
|
SPDLOG_INLINE int utc_minutes_offset(const std::tm &tm) {
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#if _WIN32_WINNT < _WIN32_WINNT_WS08
|
#if _WIN32_WINNT < _WIN32_WINNT_WS08
|
||||||
TIME_ZONE_INFORMATION tzinfo;
|
TIME_ZONE_INFORMATION tzinfo;
|
||||||
@ -258,8 +254,7 @@ SPDLOG_INLINE int utc_minutes_offset(const std::tm &tm) {
|
|||||||
DYNAMIC_TIME_ZONE_INFORMATION tzinfo;
|
DYNAMIC_TIME_ZONE_INFORMATION tzinfo;
|
||||||
auto rv = ::GetDynamicTimeZoneInformation(&tzinfo);
|
auto rv = ::GetDynamicTimeZoneInformation(&tzinfo);
|
||||||
#endif
|
#endif
|
||||||
if (rv == TIME_ZONE_ID_INVALID)
|
if (rv == TIME_ZONE_ID_INVALID) throw_spdlog_ex("Failed getting timezone info. ", errno);
|
||||||
throw_spdlog_ex("Failed getting timezone info. ", errno);
|
|
||||||
|
|
||||||
int offset = -tzinfo.Bias;
|
int offset = -tzinfo.Bias;
|
||||||
if (tm.tm_isdst) {
|
if (tm.tm_isdst) {
|
||||||
@ -388,7 +383,6 @@ SPDLOG_INLINE std::string filename_to_str(const filename_t &filename) { return f
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
SPDLOG_INLINE int pid() SPDLOG_NOEXCEPT {
|
SPDLOG_INLINE int pid() SPDLOG_NOEXCEPT {
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
return conditional_static_cast<int>(::GetCurrentProcessId());
|
return conditional_static_cast<int>(::GetCurrentProcessId());
|
||||||
#else
|
#else
|
||||||
@ -430,7 +424,6 @@ SPDLOG_INLINE bool is_color_terminal() SPDLOG_NOEXCEPT {
|
|||||||
// Determine if the terminal attached
|
// Determine if the terminal attached
|
||||||
// Source: https://github.com/agauniyal/rang/
|
// Source: https://github.com/agauniyal/rang/
|
||||||
SPDLOG_INLINE bool in_terminal(FILE *file) SPDLOG_NOEXCEPT {
|
SPDLOG_INLINE bool in_terminal(FILE *file) SPDLOG_NOEXCEPT {
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
return ::_isatty(_fileno(file)) != 0;
|
return ::_isatty(_fileno(file)) != 0;
|
||||||
#else
|
#else
|
||||||
@ -556,7 +549,6 @@ SPDLOG_INLINE filename_t dir_name(const filename_t &path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string SPDLOG_INLINE getenv(const char *field) {
|
std::string SPDLOG_INLINE getenv(const char *field) {
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
#if defined(__cplusplus_winrt)
|
#if defined(__cplusplus_winrt)
|
||||||
return std::string{}; // not supported under uwp
|
return std::string{}; // not supported under uwp
|
||||||
|
@ -32,7 +32,6 @@ namespace details {
|
|||||||
|
|
||||||
SPDLOG_INLINE registry::registry()
|
SPDLOG_INLINE registry::registry()
|
||||||
: formatter_(new pattern_formatter()) {
|
: formatter_(new pattern_formatter()) {
|
||||||
|
|
||||||
#ifndef SPDLOG_DISABLE_DEFAULT_LOGGER
|
#ifndef SPDLOG_DISABLE_DEFAULT_LOGGER
|
||||||
// create default logger (ansicolor_stdout_sink_mt or wincolor_stdout_sink_mt in windows).
|
// create default logger (ansicolor_stdout_sink_mt or wincolor_stdout_sink_mt in windows).
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@ -170,8 +169,8 @@ SPDLOG_INLINE void registry::set_error_handler(err_handler handler) {
|
|||||||
err_handler_ = std::move(handler);
|
err_handler_ = std::move(handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
SPDLOG_INLINE void
|
SPDLOG_INLINE void registry::apply_all(
|
||||||
registry::apply_all(const std::function<void(const std::shared_ptr<logger>)> &fun) {
|
const std::function<void(const std::shared_ptr<logger>)> &fun) {
|
||||||
std::lock_guard<std::mutex> lock(logger_map_mutex_);
|
std::lock_guard<std::mutex> lock(logger_map_mutex_);
|
||||||
for (auto &l : loggers_) {
|
for (auto &l : loggers_) {
|
||||||
fun(l.second);
|
fun(l.second);
|
||||||
|
@ -19,7 +19,8 @@ SPDLOG_INLINE thread_pool::thread_pool(size_t q_max_items,
|
|||||||
std::function<void()> on_thread_stop)
|
std::function<void()> on_thread_stop)
|
||||||
: q_(q_max_items) {
|
: q_(q_max_items) {
|
||||||
if (threads_n == 0 || threads_n > 1000) {
|
if (threads_n == 0 || threads_n > 1000) {
|
||||||
throw_spdlog_ex("spdlog::thread_pool(): invalid threads_n param (valid "
|
throw_spdlog_ex(
|
||||||
|
"spdlog::thread_pool(): invalid threads_n param (valid "
|
||||||
"range is 1-1000)");
|
"range is 1-1000)");
|
||||||
}
|
}
|
||||||
for (size_t i = 0; i < threads_n; i++) {
|
for (size_t i = 0; i < threads_n; i++) {
|
||||||
|
@ -71,8 +71,8 @@ inline details::dump_info<typename Container::const_iterator> to_hex(const Conta
|
|||||||
#if __cpp_lib_span >= 202002L
|
#if __cpp_lib_span >= 202002L
|
||||||
|
|
||||||
template <typename Value, size_t Extent>
|
template <typename Value, size_t Extent>
|
||||||
inline details::dump_info<typename std::span<Value, Extent>::iterator>
|
inline details::dump_info<typename std::span<Value, Extent>::iterator> to_hex(
|
||||||
to_hex(const std::span<Value, Extent> &container, size_t size_per_line = 32) {
|
const std::span<Value, Extent> &container, size_t size_per_line = 32) {
|
||||||
using Container = std::span<Value, Extent>;
|
using Container = std::span<Value, Extent>;
|
||||||
static_assert(sizeof(typename Container::value_type) == 1,
|
static_assert(sizeof(typename Container::value_type) == 1,
|
||||||
"sizeof(Container::value_type) != 1");
|
"sizeof(Container::value_type) != 1");
|
||||||
@ -84,8 +84,9 @@ to_hex(const std::span<Value, Extent> &container, size_t size_per_line = 32) {
|
|||||||
|
|
||||||
// create dump_info from ranges
|
// create dump_info from ranges
|
||||||
template <typename It>
|
template <typename It>
|
||||||
inline details::dump_info<It>
|
inline details::dump_info<It> to_hex(const It range_begin,
|
||||||
to_hex(const It range_begin, const It range_end, size_t size_per_line = 32) {
|
const It range_end,
|
||||||
|
size_t size_per_line = 32) {
|
||||||
return details::dump_info<It>(range_begin, range_end, size_per_line);
|
return details::dump_info<It>(range_begin, range_end, size_per_line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,8 +121,9 @@ SPDLOG_INLINE std::shared_ptr<logger> logger::clone(std::string logger_name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// protected methods
|
// protected methods
|
||||||
SPDLOG_INLINE void
|
SPDLOG_INLINE void logger::log_it_(const spdlog::details::log_msg &log_msg,
|
||||||
logger::log_it_(const spdlog::details::log_msg &log_msg, bool log_enabled, bool traceback_enabled) {
|
bool log_enabled,
|
||||||
|
bool traceback_enabled) {
|
||||||
if (log_enabled) {
|
if (log_enabled) {
|
||||||
sink_it_(log_msg);
|
sink_it_(log_msg);
|
||||||
}
|
}
|
||||||
|
@ -98,8 +98,10 @@ public:
|
|||||||
log(loc, lvl, "{}", msg);
|
log(loc, lvl, "{}", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void log(log_clock::time_point log_time,
|
||||||
log(log_clock::time_point log_time, source_loc loc, level::level_enum lvl, string_view_t msg) {
|
source_loc loc,
|
||||||
|
level::level_enum lvl,
|
||||||
|
string_view_t msg) {
|
||||||
bool log_enabled = should_log(lvl);
|
bool log_enabled = should_log(lvl);
|
||||||
bool traceback_enabled = tracer_.enabled();
|
bool traceback_enabled = tracer_.enabled();
|
||||||
if (!log_enabled && !traceback_enabled) {
|
if (!log_enabled && !traceback_enabled) {
|
||||||
@ -164,8 +166,10 @@ public:
|
|||||||
log(source_loc{}, lvl, fmt, std::forward<Args>(args)...);
|
log(source_loc{}, lvl, fmt, std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void log(log_clock::time_point log_time,
|
||||||
log(log_clock::time_point log_time, source_loc loc, level::level_enum lvl, wstring_view_t msg) {
|
source_loc loc,
|
||||||
|
level::level_enum lvl,
|
||||||
|
wstring_view_t msg) {
|
||||||
bool log_enabled = should_log(lvl);
|
bool log_enabled = should_log(lvl);
|
||||||
bool traceback_enabled = tracer_.enabled();
|
bool traceback_enabled = tracer_.enabled();
|
||||||
if (!log_enabled && !traceback_enabled) {
|
if (!log_enabled && !traceback_enabled) {
|
||||||
|
@ -1167,9 +1167,9 @@ SPDLOG_INLINE void pattern_formatter::handle_flag_(char flag, details::padding_i
|
|||||||
unknown_flag->add_ch(flag);
|
unknown_flag->add_ch(flag);
|
||||||
formatters_.push_back((std::move(unknown_flag)));
|
formatters_.push_back((std::move(unknown_flag)));
|
||||||
}
|
}
|
||||||
// fix issue #1617 (prev char was '!' and should have been treated as funcname flag instead
|
// fix issue #1617 (prev char was '!' and should have been treated as funcname flag
|
||||||
// of truncating flag) spdlog::set_pattern("[%10!] %v") => "[ main] some message"
|
// instead of truncating flag) spdlog::set_pattern("[%10!] %v") => "[ main] some
|
||||||
// spdlog::set_pattern("[%3!!] %v") => "[mai] some message"
|
// message" spdlog::set_pattern("[%3!!] %v") => "[mai] some message"
|
||||||
else {
|
else {
|
||||||
padding.truncate_ = false;
|
padding.truncate_ = false;
|
||||||
formatters_.push_back(
|
formatters_.push_back(
|
||||||
@ -1185,9 +1185,8 @@ SPDLOG_INLINE void pattern_formatter::handle_flag_(char flag, details::padding_i
|
|||||||
// Extract given pad spec (e.g. %8X, %=8X, %-8!X, %8!X, %=8!X, %-8!X, %+8!X)
|
// Extract given pad spec (e.g. %8X, %=8X, %-8!X, %8!X, %=8!X, %-8!X, %+8!X)
|
||||||
// Advance the given it pass the end of the padding spec found (if any)
|
// Advance the given it pass the end of the padding spec found (if any)
|
||||||
// Return padding.
|
// Return padding.
|
||||||
SPDLOG_INLINE details::padding_info
|
SPDLOG_INLINE details::padding_info pattern_formatter::handle_padspec_(
|
||||||
pattern_formatter::handle_padspec_(std::string::const_iterator &it,
|
std::string::const_iterator &it, std::string::const_iterator end) {
|
||||||
std::string::const_iterator end) {
|
|
||||||
using details::padding_info;
|
using details::padding_info;
|
||||||
using details::scoped_padder;
|
using details::scoped_padder;
|
||||||
const size_t max_width = 64;
|
const size_t max_width = 64;
|
||||||
|
@ -43,8 +43,9 @@ public:
|
|||||||
: padinfo_(padinfo) {}
|
: padinfo_(padinfo) {}
|
||||||
flag_formatter() = default;
|
flag_formatter() = default;
|
||||||
virtual ~flag_formatter() = default;
|
virtual ~flag_formatter() = default;
|
||||||
virtual void
|
virtual void format(const details::log_msg &msg,
|
||||||
format(const details::log_msg &msg, const std::tm &tm_time, memory_buf_t &dest) = 0;
|
const std::tm &tm_time,
|
||||||
|
memory_buf_t &dest) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
padding_info padinfo_;
|
padding_info padinfo_;
|
||||||
|
@ -74,14 +74,14 @@ private:
|
|||||||
// __android_log_buf_write, if user explicitly provides a non-default log buffer. Otherwise,
|
// __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.
|
// when using the default log buffer, always log via __android_log_write.
|
||||||
template <int ID = BufferID>
|
template <int ID = BufferID>
|
||||||
typename std::enable_if<ID == static_cast<int>(log_id::LOG_ID_MAIN), int>::type
|
typename std::enable_if<ID == static_cast<int>(log_id::LOG_ID_MAIN), int>::type android_log(
|
||||||
android_log(int prio, const char *tag, const char *text) {
|
int prio, const char *tag, const char *text) {
|
||||||
return __android_log_write(prio, tag, text);
|
return __android_log_write(prio, tag, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int ID = BufferID>
|
template <int ID = BufferID>
|
||||||
typename std::enable_if<ID != static_cast<int>(log_id::LOG_ID_MAIN), int>::type
|
typename std::enable_if<ID != static_cast<int>(log_id::LOG_ID_MAIN), int>::type android_log(
|
||||||
android_log(int prio, const char *tag, const char *text) {
|
int prio, const char *tag, const char *text) {
|
||||||
return __android_log_buf_write(ID, prio, tag, text);
|
return __android_log_buf_write(ID, prio, tag, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,8 +75,8 @@ SPDLOG_INLINE void ansicolor_sink<ConsoleMutex>::set_pattern(const std::string &
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename ConsoleMutex>
|
template <typename ConsoleMutex>
|
||||||
SPDLOG_INLINE void
|
SPDLOG_INLINE void ansicolor_sink<ConsoleMutex>::set_formatter(
|
||||||
ansicolor_sink<ConsoleMutex>::set_formatter(std::unique_ptr<spdlog::formatter> sink_formatter) {
|
std::unique_ptr<spdlog::formatter> sink_formatter) {
|
||||||
std::lock_guard<mutex_t> lock(mutex_);
|
std::lock_guard<mutex_t> lock(mutex_);
|
||||||
formatter_ = std::move(sink_formatter);
|
formatter_ = std::move(sink_formatter);
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,8 @@ SPDLOG_INLINE spdlog::sinks::base_sink<Mutex>::base_sink()
|
|||||||
: formatter_{details::make_unique<spdlog::pattern_formatter>()} {}
|
: formatter_{details::make_unique<spdlog::pattern_formatter>()} {}
|
||||||
|
|
||||||
template <typename Mutex>
|
template <typename Mutex>
|
||||||
SPDLOG_INLINE
|
SPDLOG_INLINE spdlog::sinks::base_sink<Mutex>::base_sink(
|
||||||
spdlog::sinks::base_sink<Mutex>::base_sink(std::unique_ptr<spdlog::formatter> formatter)
|
std::unique_ptr<spdlog::formatter> formatter)
|
||||||
: formatter_{std::move(formatter)} {}
|
: formatter_{std::move(formatter)} {}
|
||||||
|
|
||||||
template <typename Mutex>
|
template <typename Mutex>
|
||||||
|
@ -213,8 +213,8 @@ inline std::shared_ptr<logger> daily_logger_mt(const std::string &logger_name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Factory = spdlog::synchronous_factory>
|
template <typename Factory = spdlog::synchronous_factory>
|
||||||
inline std::shared_ptr<logger>
|
inline std::shared_ptr<logger> daily_logger_format_mt(
|
||||||
daily_logger_format_mt(const std::string &logger_name,
|
const std::string &logger_name,
|
||||||
const filename_t &filename,
|
const filename_t &filename,
|
||||||
int hour = 0,
|
int hour = 0,
|
||||||
int minute = 0,
|
int minute = 0,
|
||||||
@ -238,8 +238,8 @@ inline std::shared_ptr<logger> daily_logger_st(const std::string &logger_name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Factory = spdlog::synchronous_factory>
|
template <typename Factory = spdlog::synchronous_factory>
|
||||||
inline std::shared_ptr<logger>
|
inline std::shared_ptr<logger> daily_logger_format_st(
|
||||||
daily_logger_format_st(const std::string &logger_name,
|
const std::string &logger_name,
|
||||||
const filename_t &filename,
|
const filename_t &filename,
|
||||||
int hour = 0,
|
int hour = 0,
|
||||||
int minute = 0,
|
int minute = 0,
|
||||||
|
@ -105,14 +105,14 @@ inline std::shared_ptr<logger> kafka_logger_st(const std::string &logger_name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Factory = spdlog::async_factory>
|
template <typename Factory = spdlog::async_factory>
|
||||||
inline std::shared_ptr<spdlog::logger>
|
inline std::shared_ptr<spdlog::logger> kafka_logger_async_mt(
|
||||||
kafka_logger_async_mt(std::string logger_name, spdlog::sinks::kafka_sink_config config) {
|
std::string logger_name, spdlog::sinks::kafka_sink_config config) {
|
||||||
return Factory::template create<sinks::kafka_sink_mt>(logger_name, config);
|
return Factory::template create<sinks::kafka_sink_mt>(logger_name, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Factory = spdlog::async_factory>
|
template <typename Factory = spdlog::async_factory>
|
||||||
inline std::shared_ptr<spdlog::logger>
|
inline std::shared_ptr<spdlog::logger> kafka_logger_async_st(
|
||||||
kafka_logger_async_st(std::string logger_name, spdlog::sinks::kafka_sink_config config) {
|
std::string logger_name, spdlog::sinks::kafka_sink_config config) {
|
||||||
return Factory::template create<sinks::kafka_sink_st>(logger_name, config);
|
return Factory::template create<sinks::kafka_sink_st>(logger_name, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,8 +86,8 @@ using mongo_sink_st = mongo_sink<spdlog::details::null_mutex>;
|
|||||||
} // namespace sinks
|
} // namespace sinks
|
||||||
|
|
||||||
template <typename Factory = spdlog::synchronous_factory>
|
template <typename Factory = spdlog::synchronous_factory>
|
||||||
inline std::shared_ptr<logger>
|
inline std::shared_ptr<logger> mongo_logger_mt(
|
||||||
mongo_logger_mt(const std::string &logger_name,
|
const std::string &logger_name,
|
||||||
const std::string &db_name,
|
const std::string &db_name,
|
||||||
const std::string &collection_name,
|
const std::string &collection_name,
|
||||||
const std::string &uri = "mongodb://localhost:27017") {
|
const std::string &uri = "mongodb://localhost:27017") {
|
||||||
@ -96,8 +96,8 @@ mongo_logger_mt(const std::string &logger_name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Factory = spdlog::synchronous_factory>
|
template <typename Factory = spdlog::synchronous_factory>
|
||||||
inline std::shared_ptr<logger>
|
inline std::shared_ptr<logger> mongo_logger_st(
|
||||||
mongo_logger_st(const std::string &logger_name,
|
const std::string &logger_name,
|
||||||
const std::string &db_name,
|
const std::string &db_name,
|
||||||
const std::string &collection_name,
|
const std::string &collection_name,
|
||||||
const std::string &uri = "mongodb://localhost:27017") {
|
const std::string &uri = "mongodb://localhost:27017") {
|
||||||
|
@ -269,14 +269,16 @@ inline std::shared_ptr<logger> qt_logger_st(const std::string &logger_name,
|
|||||||
}
|
}
|
||||||
// log to QObject
|
// log to QObject
|
||||||
template <typename Factory = spdlog::synchronous_factory>
|
template <typename Factory = spdlog::synchronous_factory>
|
||||||
inline std::shared_ptr<logger>
|
inline std::shared_ptr<logger> qt_logger_mt(const std::string &logger_name,
|
||||||
qt_logger_mt(const std::string &logger_name, QObject *qt_object, const std::string &meta_method) {
|
QObject *qt_object,
|
||||||
|
const std::string &meta_method) {
|
||||||
return Factory::template create<sinks::qt_sink_mt>(logger_name, qt_object, meta_method);
|
return Factory::template create<sinks::qt_sink_mt>(logger_name, qt_object, meta_method);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Factory = spdlog::synchronous_factory>
|
template <typename Factory = spdlog::synchronous_factory>
|
||||||
inline std::shared_ptr<logger>
|
inline std::shared_ptr<logger> qt_logger_st(const std::string &logger_name,
|
||||||
qt_logger_st(const std::string &logger_name, QObject *qt_object, const std::string &meta_method) {
|
QObject *qt_object,
|
||||||
|
const std::string &meta_method) {
|
||||||
return Factory::template create<sinks::qt_sink_st>(logger_name, qt_object, meta_method);
|
return Factory::template create<sinks::qt_sink_st>(logger_name, qt_object, meta_method);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,8 +24,8 @@ namespace spdlog {
|
|||||||
namespace sinks {
|
namespace sinks {
|
||||||
|
|
||||||
template <typename Mutex>
|
template <typename Mutex>
|
||||||
SPDLOG_INLINE
|
SPDLOG_INLINE rotating_file_sink<Mutex>::rotating_file_sink(
|
||||||
rotating_file_sink<Mutex>::rotating_file_sink(filename_t base_filename,
|
filename_t base_filename,
|
||||||
std::size_t max_size,
|
std::size_t max_size,
|
||||||
std::size_t max_files,
|
std::size_t max_files,
|
||||||
bool rotate_on_open,
|
bool rotate_on_open,
|
||||||
|
@ -85,8 +85,8 @@ SPDLOG_INLINE void stdout_sink_base<ConsoleMutex>::set_pattern(const std::string
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename ConsoleMutex>
|
template <typename ConsoleMutex>
|
||||||
SPDLOG_INLINE void
|
SPDLOG_INLINE void stdout_sink_base<ConsoleMutex>::set_formatter(
|
||||||
stdout_sink_base<ConsoleMutex>::set_formatter(std::unique_ptr<spdlog::formatter> sink_formatter) {
|
std::unique_ptr<spdlog::formatter> sink_formatter) {
|
||||||
std::lock_guard<mutex_t> lock(mutex_);
|
std::lock_guard<mutex_t> lock(mutex_);
|
||||||
formatter_ = std::move(sink_formatter);
|
formatter_ = std::move(sink_formatter);
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ namespace sinks {
|
|||||||
*/
|
*/
|
||||||
template <typename Mutex>
|
template <typename Mutex>
|
||||||
class syslog_sink : public base_sink<Mutex> {
|
class syslog_sink : public base_sink<Mutex> {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
syslog_sink(std::string ident, int syslog_option, int syslog_facility, bool enable_formatting)
|
syslog_sink(std::string ident, int syslog_option, int syslog_facility, bool enable_formatting)
|
||||||
: enable_formatting_{enable_formatting},
|
: enable_formatting_{enable_formatting},
|
||||||
|
@ -247,8 +247,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
~win_eventlog_sink() {
|
~win_eventlog_sink() {
|
||||||
if (hEventLog_)
|
if (hEventLog_) DeregisterEventSource(hEventLog_);
|
||||||
DeregisterEventSource(hEventLog_);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@ SPDLOG_INLINE wincolor_sink<ConsoleMutex>::wincolor_sink(void *out_handle, color
|
|||||||
: out_handle_(out_handle),
|
: out_handle_(out_handle),
|
||||||
mutex_(ConsoleMutex::mutex()),
|
mutex_(ConsoleMutex::mutex()),
|
||||||
formatter_(details::make_unique<spdlog::pattern_formatter>()) {
|
formatter_(details::make_unique<spdlog::pattern_formatter>()) {
|
||||||
|
|
||||||
set_color_mode_impl(mode);
|
set_color_mode_impl(mode);
|
||||||
// set level colors
|
// set level colors
|
||||||
colors_[level::trace] = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; // white
|
colors_[level::trace] = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; // white
|
||||||
|
@ -141,8 +141,10 @@ SPDLOG_API void set_default_logger(std::shared_ptr<spdlog::logger> default_logge
|
|||||||
SPDLOG_API void apply_logger_env_levels(std::shared_ptr<logger> logger);
|
SPDLOG_API void apply_logger_env_levels(std::shared_ptr<logger> logger);
|
||||||
|
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
inline void
|
inline void log(source_loc source,
|
||||||
log(source_loc source, level::level_enum lvl, format_string_t<Args...> fmt, Args &&...args) {
|
level::level_enum lvl,
|
||||||
|
format_string_t<Args...> fmt,
|
||||||
|
Args &&...args) {
|
||||||
default_logger_raw()->log(source, lvl, fmt, std::forward<Args>(args)...);
|
default_logger_raw()->log(source, lvl, fmt, std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,8 +195,10 @@ inline void log(level::level_enum lvl, const T &msg) {
|
|||||||
|
|
||||||
#ifdef SPDLOG_WCHAR_TO_UTF8_SUPPORT
|
#ifdef SPDLOG_WCHAR_TO_UTF8_SUPPORT
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
inline void
|
inline void log(source_loc source,
|
||||||
log(source_loc source, level::level_enum lvl, wformat_string_t<Args...> fmt, Args &&...args) {
|
level::level_enum lvl,
|
||||||
|
wformat_string_t<Args...> fmt,
|
||||||
|
Args &&...args) {
|
||||||
default_logger_raw()->log(source, lvl, fmt, std::forward<Args>(args)...);
|
default_logger_raw()->log(source, lvl, fmt, std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,8 +31,10 @@ template FMT_API void buffer<char>::append(const char *, const char *);
|
|||||||
// DEPRECATED!
|
// DEPRECATED!
|
||||||
// There is no correspondent extern template in format.h because of
|
// There is no correspondent extern template in format.h because of
|
||||||
// incompatibility between clang and gcc (#2377).
|
// incompatibility between clang and gcc (#2377).
|
||||||
template FMT_API void
|
template FMT_API void vformat_to(buffer<char> &,
|
||||||
vformat_to(buffer<char> &, string_view, basic_format_args<FMT_BUFFER_CONTEXT(char)>, locale_ref);
|
string_view,
|
||||||
|
basic_format_args<FMT_BUFFER_CONTEXT(char)>,
|
||||||
|
locale_ref);
|
||||||
|
|
||||||
// Explicit instantiations for wchar_t.
|
// Explicit instantiations for wchar_t.
|
||||||
|
|
||||||
|
@ -45,11 +45,11 @@ template SPDLOG_API std::shared_ptr<spdlog::logger>
|
|||||||
spdlog::stderr_color_st<spdlog::synchronous_factory>(const std::string &logger_name,
|
spdlog::stderr_color_st<spdlog::synchronous_factory>(const std::string &logger_name,
|
||||||
color_mode mode);
|
color_mode mode);
|
||||||
|
|
||||||
template SPDLOG_API std::shared_ptr<spdlog::logger>
|
template SPDLOG_API std::shared_ptr<spdlog::logger> spdlog::stdout_color_mt<spdlog::async_factory>(
|
||||||
spdlog::stdout_color_mt<spdlog::async_factory>(const std::string &logger_name, color_mode mode);
|
const std::string &logger_name, color_mode mode);
|
||||||
template SPDLOG_API std::shared_ptr<spdlog::logger>
|
template SPDLOG_API std::shared_ptr<spdlog::logger> spdlog::stdout_color_st<spdlog::async_factory>(
|
||||||
spdlog::stdout_color_st<spdlog::async_factory>(const std::string &logger_name, color_mode mode);
|
const std::string &logger_name, color_mode mode);
|
||||||
template SPDLOG_API std::shared_ptr<spdlog::logger>
|
template SPDLOG_API std::shared_ptr<spdlog::logger> spdlog::stderr_color_mt<spdlog::async_factory>(
|
||||||
spdlog::stderr_color_mt<spdlog::async_factory>(const std::string &logger_name, color_mode mode);
|
const std::string &logger_name, color_mode mode);
|
||||||
template SPDLOG_API std::shared_ptr<spdlog::logger>
|
template SPDLOG_API std::shared_ptr<spdlog::logger> spdlog::stderr_color_st<spdlog::async_factory>(
|
||||||
spdlog::stderr_color_st<spdlog::async_factory>(const std::string &logger_name, color_mode mode);
|
const std::string &logger_name, color_mode mode);
|
||||||
|
@ -27,11 +27,11 @@ spdlog::stderr_logger_mt<spdlog::synchronous_factory>(const std::string &logger_
|
|||||||
template SPDLOG_API std::shared_ptr<spdlog::logger>
|
template SPDLOG_API std::shared_ptr<spdlog::logger>
|
||||||
spdlog::stderr_logger_st<spdlog::synchronous_factory>(const std::string &logger_name);
|
spdlog::stderr_logger_st<spdlog::synchronous_factory>(const std::string &logger_name);
|
||||||
|
|
||||||
template SPDLOG_API std::shared_ptr<spdlog::logger>
|
template SPDLOG_API std::shared_ptr<spdlog::logger> spdlog::stdout_logger_mt<spdlog::async_factory>(
|
||||||
spdlog::stdout_logger_mt<spdlog::async_factory>(const std::string &logger_name);
|
const std::string &logger_name);
|
||||||
template SPDLOG_API std::shared_ptr<spdlog::logger>
|
template SPDLOG_API std::shared_ptr<spdlog::logger> spdlog::stdout_logger_st<spdlog::async_factory>(
|
||||||
spdlog::stdout_logger_st<spdlog::async_factory>(const std::string &logger_name);
|
const std::string &logger_name);
|
||||||
template SPDLOG_API std::shared_ptr<spdlog::logger>
|
template SPDLOG_API std::shared_ptr<spdlog::logger> spdlog::stderr_logger_mt<spdlog::async_factory>(
|
||||||
spdlog::stderr_logger_mt<spdlog::async_factory>(const std::string &logger_name);
|
const std::string &logger_name);
|
||||||
template SPDLOG_API std::shared_ptr<spdlog::logger>
|
template SPDLOG_API std::shared_ptr<spdlog::logger> spdlog::stderr_logger_st<spdlog::async_factory>(
|
||||||
spdlog::stderr_logger_st<spdlog::async_factory>(const std::string &logger_name);
|
const std::string &logger_name);
|
||||||
|
@ -94,7 +94,6 @@ TEST_CASE("flush", "[async]") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("async periodic flush", "[async]") {
|
TEST_CASE("async periodic flush", "[async]") {
|
||||||
|
|
||||||
auto logger = spdlog::create_async<spdlog::sinks::test_sink_mt>("as");
|
auto logger = spdlog::create_async<spdlog::sinks::test_sink_mt>("as");
|
||||||
auto test_sink = std::static_pointer_cast<spdlog::sinks::test_sink_mt>(logger->sinks()[0]);
|
auto test_sink = std::static_pointer_cast<spdlog::sinks::test_sink_mt>(logger->sinks()[0]);
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
#include "spdlog/async.h"
|
#include "spdlog/async.h"
|
||||||
|
|
||||||
TEST_CASE("bactrace1", "[bactrace]") {
|
TEST_CASE("bactrace1", "[bactrace]") {
|
||||||
|
|
||||||
using spdlog::sinks::test_sink_st;
|
using spdlog::sinks::test_sink_st;
|
||||||
auto test_sink = std::make_shared<test_sink_st>();
|
auto test_sink = std::make_shared<test_sink_st>();
|
||||||
size_t backtrace_size = 5;
|
size_t backtrace_size = 5;
|
||||||
@ -13,8 +12,7 @@ TEST_CASE("bactrace1", "[bactrace]") {
|
|||||||
logger.enable_backtrace(backtrace_size);
|
logger.enable_backtrace(backtrace_size);
|
||||||
|
|
||||||
logger.info("info message");
|
logger.info("info message");
|
||||||
for (int i = 0; i < 100; i++)
|
for (int i = 0; i < 100; i++) logger.debug("debug message {}", i);
|
||||||
logger.debug("debug message {}", i);
|
|
||||||
|
|
||||||
REQUIRE(test_sink->lines().size() == 1);
|
REQUIRE(test_sink->lines().size() == 1);
|
||||||
REQUIRE(test_sink->lines()[0] == "info message");
|
REQUIRE(test_sink->lines()[0] == "info message");
|
||||||
@ -56,8 +54,7 @@ TEST_CASE("bactrace-async", "[bactrace]") {
|
|||||||
logger->enable_backtrace(backtrace_size);
|
logger->enable_backtrace(backtrace_size);
|
||||||
|
|
||||||
logger->info("info message");
|
logger->info("info message");
|
||||||
for (int i = 0; i < 100; i++)
|
for (int i = 0; i < 100; i++) logger->debug("debug message {}", i);
|
||||||
logger->debug("debug message {}", i);
|
|
||||||
|
|
||||||
sleep_for_millis(100);
|
sleep_for_millis(100);
|
||||||
REQUIRE(test_sink->lines().size() == 1);
|
REQUIRE(test_sink->lines().size() == 1);
|
||||||
|
@ -37,7 +37,6 @@ TEST_CASE("daily_logger with dateonly calculator", "[daily_logger]") {
|
|||||||
|
|
||||||
auto logger = spdlog::create<sink_type>("logger", basename, 0, 0);
|
auto logger = spdlog::create<sink_type>("logger", basename, 0, 0);
|
||||||
for (int i = 0; i < 10; ++i) {
|
for (int i = 0; i < 10; ++i) {
|
||||||
|
|
||||||
logger->info("Test message {}", i);
|
logger->info("Test message {}", i);
|
||||||
}
|
}
|
||||||
logger->flush();
|
logger->flush();
|
||||||
|
@ -100,8 +100,7 @@ TEST_CASE("async_error_handler2", "[errors]") {
|
|||||||
auto logger = spdlog::create_async<failing_sink>("failed_logger");
|
auto logger = spdlog::create_async<failing_sink>("failed_logger");
|
||||||
logger->set_error_handler([=](const std::string &) {
|
logger->set_error_handler([=](const std::string &) {
|
||||||
std::ofstream ofs("test_logs/custom_err2.txt");
|
std::ofstream ofs("test_logs/custom_err2.txt");
|
||||||
if (!ofs)
|
if (!ofs) throw std::runtime_error("Failed open test_logs/custom_err2.txt");
|
||||||
throw std::runtime_error("Failed open test_logs/custom_err2.txt");
|
|
||||||
ofs << err_msg;
|
ofs << err_msg;
|
||||||
});
|
});
|
||||||
logger->info("Hello failure");
|
logger->info("Hello failure");
|
||||||
|
@ -85,7 +85,6 @@ TEST_CASE("rotating_file_logger2", "[rotating_logger]") {
|
|||||||
require_message_count(ROTATING_LOG, 10);
|
require_message_count(ROTATING_LOG, 10);
|
||||||
|
|
||||||
for (int i = 0; i < 1000; i++) {
|
for (int i = 0; i < 1000; i++) {
|
||||||
|
|
||||||
logger->info("Test message {}", i);
|
logger->info("Test message {}", i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
#define TEST_FILENAME "test_logs/simple_log"
|
#define TEST_FILENAME "test_logs/simple_log"
|
||||||
|
|
||||||
TEST_CASE("debug and trace w/o format string", "[macros]") {
|
TEST_CASE("debug and trace w/o format string", "[macros]") {
|
||||||
|
|
||||||
prepare_logdir();
|
prepare_logdir();
|
||||||
spdlog::filename_t filename = SPDLOG_FILENAME_T(TEST_FILENAME);
|
spdlog::filename_t filename = SPDLOG_FILENAME_T(TEST_FILENAME);
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
std::string log_info(const T &what, spdlog::level::level_enum logger_level = spdlog::level::info) {
|
std::string log_info(const T &what, spdlog::level::level_enum logger_level = spdlog::level::info) {
|
||||||
|
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
auto oss_sink = std::make_shared<spdlog::sinks::ostream_sink_mt>(oss);
|
auto oss_sink = std::make_shared<spdlog::sinks::ostream_sink_mt>(oss);
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@ TEST_CASE("dequeue-empty-nowait", "[mpmc_blocking_q]") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("dequeue-empty-wait", "[mpmc_blocking_q]") {
|
TEST_CASE("dequeue-empty-wait", "[mpmc_blocking_q]") {
|
||||||
|
|
||||||
size_t q_size = 100;
|
size_t q_size = 100;
|
||||||
milliseconds wait_ms(250);
|
milliseconds wait_ms(250);
|
||||||
milliseconds tolerance_wait(250);
|
milliseconds tolerance_wait(250);
|
||||||
@ -59,7 +58,6 @@ TEST_CASE("dequeue-full-wait", "[mpmc_blocking_q]") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("enqueue_nowait", "[mpmc_blocking_q]") {
|
TEST_CASE("enqueue_nowait", "[mpmc_blocking_q]") {
|
||||||
|
|
||||||
size_t q_size = 1;
|
size_t q_size = 1;
|
||||||
spdlog::details::mpmc_blocking_queue<int> q(q_size);
|
spdlog::details::mpmc_blocking_queue<int> q(q_size);
|
||||||
milliseconds tolerance_wait(10);
|
milliseconds tolerance_wait(10);
|
||||||
|
@ -35,8 +35,7 @@ std::size_t count_lines(const std::string &filename) {
|
|||||||
|
|
||||||
std::string line;
|
std::string line;
|
||||||
size_t counter = 0;
|
size_t counter = 0;
|
||||||
while (std::getline(ifs, line))
|
while (std::getline(ifs, line)) counter++;
|
||||||
counter++;
|
|
||||||
return counter;
|
return counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,8 +75,7 @@ std::size_t count_files(const std::string &folder) {
|
|||||||
if (hFind != INVALID_HANDLE_VALUE) {
|
if (hFind != INVALID_HANDLE_VALUE) {
|
||||||
do // Managed to locate and create an handle to that folder.
|
do // Managed to locate and create an handle to that folder.
|
||||||
{
|
{
|
||||||
if (ffd.cFileName[0] != '.')
|
if (ffd.cFileName[0] != '.') counter++;
|
||||||
counter++;
|
|
||||||
} while (::FindNextFileA(hFind, &ffd) != 0);
|
} while (::FindNextFileA(hFind, &ffd) != 0);
|
||||||
::FindClose(hFind);
|
::FindClose(hFind);
|
||||||
} else {
|
} else {
|
||||||
@ -97,8 +95,7 @@ std::size_t count_files(const std::string &folder) {
|
|||||||
|
|
||||||
struct dirent *ep = nullptr;
|
struct dirent *ep = nullptr;
|
||||||
while ((ep = readdir(dp)) != nullptr) {
|
while ((ep = readdir(dp)) != nullptr) {
|
||||||
if (ep->d_name[0] != '.')
|
if (ep->d_name[0] != '.') counter++;
|
||||||
counter++;
|
|
||||||
}
|
}
|
||||||
(void)closedir(dp);
|
(void)closedir(dp);
|
||||||
return counter;
|
return counter;
|
||||||
|
Loading…
Reference in New Issue
Block a user