Commit bf3997de authored by gabi's avatar gabi

Added drop_all

parent 3c57133c
...@@ -78,6 +78,11 @@ public: ...@@ -78,6 +78,11 @@ public:
_loggers.erase(logger_name); _loggers.erase(logger_name);
} }
void drop_all()
{
std::lock_guard<std::mutex> lock(_mutex);
_loggers.clear();
}
std::shared_ptr<logger> create(const std::string& logger_name, sinks_init_list sinks) std::shared_ptr<logger> create(const std::string& logger_name, sinks_init_list sinks)
{ {
return create(logger_name, sinks.begin(), sinks.end()); return create(logger_name, sinks.begin(), sinks.end());
......
...@@ -142,4 +142,8 @@ inline void spdlog::set_sync_mode() ...@@ -142,4 +142,8 @@ inline void spdlog::set_sync_mode()
details::registry::instance().set_sync_mode(); details::registry::instance().set_sync_mode();
} }
inline void spdlog::drop_all()
{
details::registry::instance().drop_all();
}
...@@ -42,10 +42,7 @@ namespace spdlog ...@@ -42,10 +42,7 @@ namespace spdlog
// logger.info() << "This is another message" << x << y << z; // logger.info() << "This is another message" << x << y << z;
std::shared_ptr<logger> get(const std::string& name); std::shared_ptr<logger> get(const std::string& name);
//
// Drop the reference to this logger.
//
void drop(const std::string &name);
// //
// Set global formatting // Set global formatting
...@@ -138,6 +135,15 @@ std::shared_ptr<spdlog::logger> create(const std::string& logger_name, const Arg ...@@ -138,6 +135,15 @@ std::shared_ptr<spdlog::logger> create(const std::string& logger_name, const Arg
#define SPDLOG_DEBUG(logger, ...) #define SPDLOG_DEBUG(logger, ...)
#endif #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" #include "details/spdlog_impl.h"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment