spdlog-python icon indicating copy to clipboard operation
spdlog-python copied to clipboard

add bindings for mux (distribution) sink; and duplication filter sink

Open justagist opened this issue 9 months ago • 0 comments

This PR adds binds for dist_sink (distribution sink; mux), and duplicate message filter sink, essentially relating to the spdlog feature request mentioned here: https://github.com/gabime/spdlog/issues/696#issuecomment-506512858.

Code to get equivalent behaviour in python:

import spdlog as spd

dup_filter = spd.dup_filter_sink_st(max_skip_duration_seconds=5.0)
dup_filter.add_sink(spd.stdout_color_sink_mt())
l = spd.SinkLogger("logger", [dup_filter])
l.info("Hello")
l.info("Hello")
l.info("Hello")
l.info("Different Hello")

Produces output: [2024-04-30 21:05:37.584] [logger] [info] Hello [2024-04-30 21:05:37.585] [logger] [info] Skipped 2 duplicate messages.. [2024-04-30 21:05:37.585] [logger] [info] Different Hello

justagist avatar Apr 30 '24 20:04 justagist