Merge remote-tracking branch 'origin/v1.x' into conf-env3

This commit is contained in:
gabime 2020-03-06 15:10:24 +02:00
commit efd73ac956
9 changed files with 12 additions and 20 deletions

View File

@ -39,7 +39,7 @@ $ cmake .. && make -j
* Headers only, just copy and use. Or use as a compiled library. * Headers only, just copy and use. Or use as a compiled library.
* Feature rich formatting, using the excellent [fmt](https://github.com/fmtlib/fmt) library. * Feature rich formatting, using the excellent [fmt](https://github.com/fmtlib/fmt) library.
* **New!** [Backtrace](#backtrace-support) support - store debug messages in a ring buffer and display later on demand. * **New!** [Backtrace](#backtrace-support) support - store debug messages in a ring buffer and display later on demand.
* Fast asynchronous mode (optional) * Asynchronous mode (optional)
* [Custom](https://github.com/gabime/spdlog/wiki/3.-Custom-formatting) formatting. * [Custom](https://github.com/gabime/spdlog/wiki/3.-Custom-formatting) formatting.
* Multi/Single threaded loggers. * Multi/Single threaded loggers.
* Various log targets: * Various log targets:
@ -300,15 +300,6 @@ void android_example()
android_logger->critical("Use \"adb shell logcat\" to view this message."); android_logger->critical("Use \"adb shell logcat\" to view this message.");
} }
``` ```
---
#### Compile-time format string syntax checking
```C++
#include "spdlog/spdlog.h"
int main()
{
spdlog::info(FMT_STRING("{:d} is an invalid format tag"));
}
```
## Benchmarks ## Benchmarks

View File

@ -390,13 +390,13 @@ SPDLOG_INLINE int pid() SPDLOG_NOEXCEPT
} }
// Determine if the terminal supports colors // Determine if the terminal supports colors
// Source: https://github.com/agauniyal/rang/ // Based on: https://github.com/agauniyal/rang/
SPDLOG_INLINE bool is_color_terminal() SPDLOG_NOEXCEPT SPDLOG_INLINE bool is_color_terminal() SPDLOG_NOEXCEPT
{ {
#ifdef _WIN32 #ifdef _WIN32
return true; return true;
#else #else
static constexpr std::array<const char *, 14> Terms = { static constexpr std::array<const char *, 14> terms = {
{"ansi", "color", "console", "cygwin", "gnome", "konsole", "kterm", "linux", "msys", "putty", "rxvt", "screen", "vt100", "xterm"}}; {"ansi", "color", "console", "cygwin", "gnome", "konsole", "kterm", "linux", "msys", "putty", "rxvt", "screen", "vt100", "xterm"}};
const char *env_p = std::getenv("TERM"); const char *env_p = std::getenv("TERM");
@ -406,7 +406,7 @@ SPDLOG_INLINE bool is_color_terminal() SPDLOG_NOEXCEPT
} }
static const bool result = static const bool result =
std::any_of(std::begin(Terms), std::end(Terms), [&](const char *term) { return std::strstr(env_p, term) != nullptr; }); std::any_of(terms.begin(), terms.end(), [&](const char *term) { return std::strstr(env_p, term) != nullptr; });
return result; return result;
#endif #endif
} }

View File

@ -92,7 +92,7 @@ private:
// Extract given pad spec (e.g. %8X) // Extract given pad spec (e.g. %8X)
// 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.
details::padding_info handle_padspec_(std::string::const_iterator &it, std::string::const_iterator end); static details::padding_info handle_padspec_(std::string::const_iterator &it, std::string::const_iterator end);
void compile_pattern_(const std::string &pattern); void compile_pattern_(const std::string &pattern);
}; };

View File

@ -184,7 +184,7 @@ SPDLOG_INLINE void registry::flush_on(level::level_enum log_level)
SPDLOG_INLINE void registry::flush_every(std::chrono::seconds interval) SPDLOG_INLINE void registry::flush_every(std::chrono::seconds interval)
{ {
std::lock_guard<std::mutex> lock(flusher_mutex_); std::lock_guard<std::mutex> lock(flusher_mutex_);
std::function<void()> clbk = std::bind(&registry::flush_all, this); auto clbk = [this](){this->flush_all();};
periodic_flusher_ = details::make_unique<periodic_worker>(clbk, interval); periodic_flusher_ = details::make_unique<periodic_worker>(clbk, interval);
} }

View File

@ -54,8 +54,8 @@ public:
void connect(const std::string &host, int port) void connect(const std::string &host, int port)
{ {
close(); close();
spdlog::info("Connecting.."); struct addrinfo hints
struct addrinfo hints{}; {};
memset(&hints, 0, sizeof(struct addrinfo)); memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_INET; // IPv4 hints.ai_family = AF_INET; // IPv4
hints.ai_socktype = SOCK_STREAM; // TCP hints.ai_socktype = SOCK_STREAM; // TCP

View File

@ -113,7 +113,7 @@ bool SPDLOG_INLINE thread_pool::process_next_msg_()
} }
default: { default: {
assert(false && "Unexpected async_msg_type"); assert(false);
} }
} }

View File

@ -89,6 +89,7 @@ SPDLOG_INLINE void logger::set_formatter(std::unique_ptr<formatter> f)
{ {
// last element - we can be move it. // last element - we can be move it.
(*it)->set_formatter(std::move(f)); (*it)->set_formatter(std::move(f));
break; // to prevent clang-tidy warning
} }
else else
{ {

View File

@ -73,7 +73,7 @@ struct win32_error : public spdlog_ex
return fmt::format("{}: {}{}", user_message, error_code, system_message); return fmt::format("{}: {}{}", user_message, error_code, system_message);
} }
win32_error(std::string const &func_name, DWORD error = GetLastError()) explicit win32_error(std::string const &func_name, DWORD error = GetLastError())
: spdlog_ex(format(func_name, error)) : spdlog_ex(format(func_name, error))
{} {}
}; };

View File

@ -9,7 +9,7 @@ class failing_sink : public spdlog::sinks::base_sink<std::mutex>
{ {
public: public:
failing_sink() = default; failing_sink() = default;
~failing_sink() final = default; ~failing_sink() = default;
protected: protected:
void sink_it_(const spdlog::details::log_msg &) final void sink_it_(const spdlog::details::log_msg &) final