From 4ccca079a56102060006761c0f59c8f6c7dd9234 Mon Sep 17 00:00:00 2001 From: gabime Date: Sun, 24 Mar 2019 01:40:20 +0200 Subject: [PATCH] clone support in lite logger --- lite-example/example.cpp | 4 ++++ lite/spdlite.cpp | 5 +++++ lite/spdlite.h | 5 +++++ 3 files changed, 14 insertions(+) diff --git a/lite-example/example.cpp b/lite-example/example.cpp index b89ddc09..34771028 100644 --- a/lite-example/example.cpp +++ b/lite-example/example.cpp @@ -9,4 +9,8 @@ int main() l.info_printf("Hello %d", 12346); l.warn_printf("Hello %f", 12346.5656); l.warn("Hello {}", "LITE :) "); + + auto l2 = l.clone("logger2"); + l2.debug("HELLO"); + } \ No newline at end of file diff --git a/lite/spdlite.cpp b/lite/spdlite.cpp index e3af7bb7..71a1aacb 100644 --- a/lite/spdlite.cpp +++ b/lite/spdlite.cpp @@ -125,6 +125,11 @@ void spdlog::lite::logger::set_pattern(std::string 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) { auto spd_level = to_spdlog_level(lvl); diff --git a/lite/spdlite.h b/lite/spdlite.h index e969678a..36a7b7af 100644 --- a/lite/spdlite.h +++ b/lite/spdlite.h @@ -174,6 +174,11 @@ public: // void set_pattern(std::string pattern); + // + //clone with new name + // + spdlog::lite::logger clone(std::string logger_name); + protected: std::shared_ptr impl_; void log_formatted_(lite::level lvl, const fmt::memory_buffer &formatted);