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