1
0
mirror of https://github.com/gabime/spdlog.git synced 2025-04-29 12:03:53 +00:00

Compare commits

...

6 Commits

Author SHA1 Message Date
Hinageshi
548b264254
Fix warning C4530 (#3393)
* Fix warning C4530

* Rename FMT_EXCEPTIONS to FMT_USE_EXCEPTIONS
2025-04-23 19:46:25 +03:00
Tihran Katolikian
847db3375f
dup_filter_sink: remove notification_level argument; use last message log level for notification instead (#3390) 2025-04-18 20:45:56 +03:00
Dmitry Kozlovtsev
bb8694b50f
Fix links for #3380 (#3381) 2025-04-14 19:22:47 +03:00
Christoph Gringmuth
cec28bf839
Fix links to local reference. (#3378)
Enables local navigation in IDE and removes links to branch.
2025-04-10 17:58:19 +03:00
Gabi Melman
bd0609d7a0
Update README.md 2025-04-10 17:06:12 +03:00
Christoph Gringmuth
1f4959c832
Fix link to wiki. (#3377) 2025-04-10 17:04:23 +03:00
3 changed files with 14 additions and 13 deletions

View File

@ -304,12 +304,13 @@ endif ()
# --------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------
if (SPDLOG_NO_EXCEPTIONS) if (SPDLOG_NO_EXCEPTIONS)
if (NOT SPDLOG_FMT_EXTERNAL AND NOT SPDLOG_FMT_EXTERNAL_HO) if (NOT SPDLOG_FMT_EXTERNAL AND NOT SPDLOG_FMT_EXTERNAL_HO)
target_compile_definitions(spdlog PUBLIC FMT_EXCEPTIONS=0) target_compile_definitions(spdlog PUBLIC FMT_USE_EXCEPTIONS=0)
endif () endif ()
if (NOT MSVC) if (NOT MSVC)
target_compile_options(spdlog PRIVATE -fno-exceptions) target_compile_options(spdlog PRIVATE -fno-exceptions)
else () else ()
target_compile_options(spdlog PRIVATE /EHs-c-) target_compile_options(spdlog PRIVATE /EHs-c-)
target_compile_definitions(spdlog PRIVATE _HAS_EXCEPTIONS=0)
endif () endif ()
endif () endif ()
# --------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------

View File

@ -11,7 +11,7 @@ Fast C++ logging library
## Install ## Install
#### Header-only version #### Header-only version
Copy the include [folder](https://github.com/gabime/spdlog/tree/v1.x/include/spdlog) to your build tree and use a C++11 compiler. Copy the include [folder](include/spdlog) to your build tree and use a C++11 compiler.
#### Compiled version (recommended - much faster compile times) #### Compiled version (recommended - much faster compile times)
```console ```console
@ -19,7 +19,7 @@ $ git clone https://github.com/gabime/spdlog.git
$ cd spdlog && mkdir build && cd build $ cd spdlog && mkdir build && cd build
$ cmake .. && cmake --build . $ cmake .. && cmake --build .
``` ```
see example [CMakeLists.txt](https://github.com/gabime/spdlog/blob/v1.x/example/CMakeLists.txt) on how to use. see example [CMakeLists.txt](example/CMakeLists.txt) on how to use.
## Platforms ## Platforms
* Linux, FreeBSD, OpenBSD, Solaris, AIX * Linux, FreeBSD, OpenBSD, Solaris, AIX
@ -48,7 +48,7 @@ see example [CMakeLists.txt](https://github.com/gabime/spdlog/blob/v1.x/example/
* Headers only or compiled * Headers only or compiled
* 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.
* Asynchronous mode (optional) * Asynchronous mode (optional)
* [Custom](https://github.com/gabime/spdlog/wiki/3.-Custom-formatting) formatting. * [Custom](https://github.com/gabime/spdlog/wiki/Custom-formatting) formatting.
* Multi/Single threaded loggers. * Multi/Single threaded loggers.
* Various log targets: * Various log targets:
* Rotating log files. * Rotating log files.
@ -58,7 +58,7 @@ see example [CMakeLists.txt](https://github.com/gabime/spdlog/blob/v1.x/example/
* Windows event log. * Windows event log.
* Windows debugger (```OutputDebugString(..)```). * Windows debugger (```OutputDebugString(..)```).
* Log to Qt widgets ([example](#log-to-qt-with-nice-colors)). * Log to Qt widgets ([example](#log-to-qt-with-nice-colors)).
* Easily [extendable](https://github.com/gabime/spdlog/wiki/4.-Sinks#implementing-your-own-sink) with custom log targets. * Easily [extendable](https://github.com/gabime/spdlog/wiki/Sinks#implementing-your-own-sink) with custom log targets.
* Log filtering - log levels can be modified at runtime as well as compile time. * Log filtering - log levels can be modified at runtime as well as compile time.
* Support for loading log levels from argv or environment var. * Support for loading log levels from argv or environment var.
* [Backtrace](#backtrace-support) support - store debug messages in a ring buffer and display them later on demand. * [Backtrace](#backtrace-support) support - store debug messages in a ring buffer and display them later on demand.
@ -467,7 +467,7 @@ void mdc_example()
--- ---
## Benchmarks ## Benchmarks
Below are some [benchmarks](https://github.com/gabime/spdlog/blob/v1.x/bench/bench.cpp) done in Ubuntu 64 bit, Intel i7-4770 CPU @ 3.40GHz Below are some [benchmarks](bench/bench.cpp) done in Ubuntu 64 bit, Intel i7-4770 CPU @ 3.40GHz
#### Synchronous mode #### Synchronous mode
``` ```
@ -519,7 +519,8 @@ Below are some [benchmarks](https://github.com/gabime/spdlog/blob/v1.x/bench/ben
``` ```
## Documentation ## Documentation
Documentation can be found in the [wiki](https://github.com/gabime/spdlog/wiki/1.-QuickStart) pages.
Documentation can be found in the [wiki](https://github.com/gabime/spdlog/wiki) pages.
--- ---

View File

@ -40,22 +40,21 @@ template <typename Mutex>
class dup_filter_sink : public dist_sink<Mutex> { class dup_filter_sink : public dist_sink<Mutex> {
public: public:
template <class Rep, class Period> 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} {}
: max_skip_duration_{max_skip_duration},
log_level_{notification_level} {}
protected: protected:
std::chrono::microseconds max_skip_duration_; std::chrono::microseconds max_skip_duration_;
log_clock::time_point last_msg_time_; log_clock::time_point last_msg_time_;
std::string last_msg_payload_; std::string last_msg_payload_;
size_t skip_counter_ = 0; size_t skip_counter_ = 0;
level::level_enum log_level_; level::level_enum skipped_msg_log_level_ = spdlog::level::level_enum::off;
void sink_it_(const details::log_msg &msg) override { void sink_it_(const details::log_msg &msg) override {
bool filtered = filter_(msg); bool filtered = filter_(msg);
if (!filtered) { if (!filtered) {
skip_counter_ += 1; skip_counter_ += 1;
skipped_msg_log_level_ = msg.level;
return; return;
} }
@ -65,7 +64,7 @@ protected:
auto msg_size = ::snprintf(buf, sizeof(buf), "Skipped %u duplicate messages..", auto msg_size = ::snprintf(buf, sizeof(buf), "Skipped %u duplicate messages..",
static_cast<unsigned>(skip_counter_)); static_cast<unsigned>(skip_counter_));
if (msg_size > 0 && static_cast<size_t>(msg_size) < sizeof(buf)) { if (msg_size > 0 && static_cast<size_t>(msg_size) < sizeof(buf)) {
details::log_msg skipped_msg{msg.source, msg.logger_name, log_level_, details::log_msg skipped_msg{msg.source, msg.logger_name, skipped_msg_log_level_,
string_view_t{buf, static_cast<size_t>(msg_size)}}; string_view_t{buf, static_cast<size_t>(msg_size)}};
dist_sink<Mutex>::sink_it_(skipped_msg); dist_sink<Mutex>::sink_it_(skipped_msg);
} }