Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions include/spdlog/sinks/dup_filter_sink.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ class dup_filter_sink : public dist_sink<Mutex> {
explicit dup_filter_sink(std::chrono::duration<Rep, Period> max_skip_duration)
: max_skip_duration_{max_skip_duration} {}

template <class Rep, class Period>
explicit dup_filter_sink(std::chrono::duration<Rep, Period> max_skip_duration, std::vector<std::shared_ptr<sink>> sinks)
: dist_sink<Mutex>(std::move(sinks))
, max_skip_duration_{max_skip_duration} {}

Copy link
Copy Markdown
Owner

@gabime gabime Mar 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

max_skip_duration should be initialized before the vector , to follow the declare order

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://en.cppreference.com/w/cpp/language/initializer_list.html

  1. Then, direct bases are initialized in left-to-right order as they appear in this class's base-specifier list.
  2. Then, non-static data member are initialized in order of declaration in the class definition.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even so, the code should be clean as possible

protected:
std::chrono::microseconds max_skip_duration_;
log_clock::time_point last_msg_time_;
Expand Down