mirror of
https://github.com/gabime/spdlog.git
synced 2025-04-29 12:03:53 +00:00
Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
548b264254 | ||
|
847db3375f | ||
|
bb8694b50f | ||
|
cec28bf839 | ||
|
bd0609d7a0 | ||
|
1f4959c832 |
@ -304,12 +304,13 @@ endif ()
|
||||
# ---------------------------------------------------------------------------------------
|
||||
if (SPDLOG_NO_EXCEPTIONS)
|
||||
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 ()
|
||||
if (NOT MSVC)
|
||||
target_compile_options(spdlog PRIVATE -fno-exceptions)
|
||||
else ()
|
||||
target_compile_options(spdlog PRIVATE /EHs-c-)
|
||||
target_compile_definitions(spdlog PRIVATE _HAS_EXCEPTIONS=0)
|
||||
endif ()
|
||||
endif ()
|
||||
# ---------------------------------------------------------------------------------------
|
||||
|
13
README.md
13
README.md
@ -11,7 +11,7 @@ Fast C++ logging library
|
||||
|
||||
## Install
|
||||
#### 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)
|
||||
```console
|
||||
@ -19,7 +19,7 @@ $ git clone https://github.com/gabime/spdlog.git
|
||||
$ cd spdlog && mkdir build && cd 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
|
||||
* 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
|
||||
* Feature-rich formatting, using the excellent [fmt](https://github.com/fmtlib/fmt) library.
|
||||
* 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.
|
||||
* Various log targets:
|
||||
* Rotating log files.
|
||||
@ -58,7 +58,7 @@ see example [CMakeLists.txt](https://github.com/gabime/spdlog/blob/v1.x/example/
|
||||
* Windows event log.
|
||||
* Windows debugger (```OutputDebugString(..)```).
|
||||
* 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.
|
||||
* 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.
|
||||
@ -467,7 +467,7 @@ void mdc_example()
|
||||
---
|
||||
## 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
|
||||
```
|
||||
@ -519,7 +519,8 @@ Below are some [benchmarks](https://github.com/gabime/spdlog/blob/v1.x/bench/ben
|
||||
```
|
||||
|
||||
## 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.
|
||||
|
||||
---
|
||||
|
||||
|
@ -40,22 +40,21 @@ template <typename Mutex>
|
||||
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,
|
||||
level::level_enum notification_level = level::info)
|
||||
: max_skip_duration_{max_skip_duration},
|
||||
log_level_{notification_level} {}
|
||||
explicit dup_filter_sink(std::chrono::duration<Rep, Period> max_skip_duration)
|
||||
: max_skip_duration_{max_skip_duration} {}
|
||||
|
||||
protected:
|
||||
std::chrono::microseconds max_skip_duration_;
|
||||
log_clock::time_point last_msg_time_;
|
||||
std::string last_msg_payload_;
|
||||
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 {
|
||||
bool filtered = filter_(msg);
|
||||
if (!filtered) {
|
||||
skip_counter_ += 1;
|
||||
skipped_msg_log_level_ = msg.level;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -65,7 +64,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.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)}};
|
||||
dist_sink<Mutex>::sink_it_(skipped_msg);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user