clone support in lite logger

This commit is contained in:
gabime 2019-03-24 01:40:20 +02:00
parent 9e5d1b3ba5
commit 4ccca079a5
3 changed files with 14 additions and 0 deletions

View File

@ -9,4 +9,8 @@ int main()
l.info_printf("Hello %d", 12346); l.info_printf("Hello %d", 12346);
l.warn_printf("Hello %f", 12346.5656); l.warn_printf("Hello %f", 12346.5656);
l.warn("Hello {}", "LITE :) "); l.warn("Hello {}", "LITE :) ");
auto l2 = l.clone("logger2");
l2.debug("HELLO");
} }

View File

@ -125,6 +125,11 @@ void spdlog::lite::logger::set_pattern(std::string pattern)
impl_->set_pattern(std::move(pattern)); impl_->set_pattern(std::move(pattern));
} }
spdlog::lite::logger spdlog::lite::logger::clone(std::string logger_name)
{
return spdlog::lite::logger(impl_->clone(std::move(logger_name)));
}
void spdlog::lite::logger::log_formatted_(spdlog::lite::level lvl, const fmt::memory_buffer &formatted) void spdlog::lite::logger::log_formatted_(spdlog::lite::level lvl, const fmt::memory_buffer &formatted)
{ {
auto spd_level = to_spdlog_level(lvl); auto spd_level = to_spdlog_level(lvl);

View File

@ -174,6 +174,11 @@ public:
// //
void set_pattern(std::string pattern); void set_pattern(std::string pattern);
//
//clone with new name
//
spdlog::lite::logger clone(std::string logger_name);
protected: protected:
std::shared_ptr<spdlog::logger> impl_; std::shared_ptr<spdlog::logger> impl_;
void log_formatted_(lite::level lvl, const fmt::memory_buffer &formatted); void log_formatted_(lite::level lvl, const fmt::memory_buffer &formatted);