Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provide the method to generate async logger with discard new overflow policy #3203

Open
wsehjk opened this issue Sep 28, 2024 · 0 comments
Open

Comments

@wsehjk
Copy link
Contributor

wsehjk commented Sep 28, 2024

I think it's better to provide create_async_discard_new method to keep consistent with the other two async logger providers create_async and create_async_nb

diff --git a/include/spdlog/async.h b/include/spdlog/async.h
index e96abd19..c0b6bb88 100644
--- a/include/spdlog/async.h
+++ b/include/spdlog/async.h
@@ -57,6 +57,7 @@ struct async_factory_impl {
 
 using async_factory = async_factory_impl<async_overflow_policy::block>;
 using async_factory_nonblock = async_factory_impl<async_overflow_policy::overrun_oldest>;
+using async_factory_discard_new = async_factory_discard_new<async_overflow_policy::discard_new>;
 
 template <typename Sink, typename... SinkArgs>
 inline std::shared_ptr<spdlog::logger> create_async(std::string logger_name,
@@ -71,6 +72,12 @@ inline std::shared_ptr<spdlog::logger> create_async_nb(std::string logger_name,
     return async_factory_nonblock::create<Sink>(std::move(logger_name),
                                                 std::forward<SinkArgs>(sink_args)...);
 }
+template <typename Sink, typename... SinkArgs>
+inline std::shared_ptr<spdlog::logger> create_async_discard_new(std::string logger_name,
+                                                       SinkArgs &&...sink_args) {
+    return async_factory_discard_new::create<Sink>(std::move(logger_name),
+                                                std::forward<SinkArgs>(sink_args)...);
+}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant