From bf3997de28300915f02b2c145a2967622e7dd1d2 Mon Sep 17 00:00:00 2001 From: gabi Date: Sat, 27 Dec 2014 13:01:15 +0200 Subject: [PATCH] Added drop_all --- include/spdlog/details/registry.h | 5 +++++ include/spdlog/details/spdlog_impl.h | 4 ++++ include/spdlog/spdlog.h | 14 ++++++++++---- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/include/spdlog/details/registry.h b/include/spdlog/details/registry.h index 96819cfc..8d815e1f 100644 --- a/include/spdlog/details/registry.h +++ b/include/spdlog/details/registry.h @@ -78,6 +78,11 @@ public: _loggers.erase(logger_name); } + void drop_all() + { + std::lock_guard lock(_mutex); + _loggers.clear(); + } std::shared_ptr create(const std::string& logger_name, sinks_init_list sinks) { return create(logger_name, sinks.begin(), sinks.end()); diff --git a/include/spdlog/details/spdlog_impl.h b/include/spdlog/details/spdlog_impl.h index 2303ee0c..2218b001 100644 --- a/include/spdlog/details/spdlog_impl.h +++ b/include/spdlog/details/spdlog_impl.h @@ -142,4 +142,8 @@ inline void spdlog::set_sync_mode() details::registry::instance().set_sync_mode(); } +inline void spdlog::drop_all() +{ + details::registry::instance().drop_all(); +} diff --git a/include/spdlog/spdlog.h b/include/spdlog/spdlog.h index 68ccb836..15be0522 100644 --- a/include/spdlog/spdlog.h +++ b/include/spdlog/spdlog.h @@ -42,10 +42,7 @@ namespace spdlog // logger.info() << "This is another message" << x << y << z; std::shared_ptr get(const std::string& name); -// -// Drop the reference to this logger. -// -void drop(const std::string &name); + // // Set global formatting @@ -138,6 +135,15 @@ std::shared_ptr create(const std::string& logger_name, const Arg #define SPDLOG_DEBUG(logger, ...) #endif + + +// Drop the reference to the given logger +void drop(const std::string &name); +// Drop all references +void drop_all(); + } + + #include "details/spdlog_impl.h"