Merge pull request #15 from xaqq/master
Add a drop() method to remove logger from the registry
This commit is contained in:
		
						commit
						54bc55a3d9
					
				@ -72,6 +72,11 @@ public:
 | 
				
			|||||||
        return new_logger;
 | 
					        return new_logger;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void drop(const std::string &logger_name)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        std::lock_guard<std::mutex> lock(_mutex);
 | 
				
			||||||
 | 
					        _loggers.erase(logger_name);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    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)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
				
			|||||||
@ -37,6 +37,10 @@ inline std::shared_ptr<spdlog::logger> spdlog::get(const std::string& name)
 | 
				
			|||||||
    return details::registry::instance().get(name);
 | 
					    return details::registry::instance().get(name);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					inline void spdlog::drop(const std::string &name)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    details::registry::instance().drop(name);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Create multi/single threaded rotating file logger
 | 
					// Create multi/single threaded rotating file logger
 | 
				
			||||||
inline std::shared_ptr<spdlog::logger> spdlog::rotating_logger_mt(const std::string& logger_name, const std::string& filename, size_t max_file_size, size_t max_files, bool auto_flush)
 | 
					inline std::shared_ptr<spdlog::logger> spdlog::rotating_logger_mt(const std::string& logger_name, const std::string& filename, size_t max_file_size, size_t max_files, bool auto_flush)
 | 
				
			||||||
 | 
				
			|||||||
@ -42,6 +42,10 @@ 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
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user