From 2ac09241777b3901e1718e983b440d4eda8800fb Mon Sep 17 00:00:00 2001 From: Daeyeon Jeong Date: Tue, 26 Mar 2024 18:51:21 +0900 Subject: [PATCH] fix: change visibility for the symbols of logger Signed-off-by: Daeyeon Jeong --- src/api/utils/logger/logger-impl.h | 13 ++++++++++--- src/api/utils/logger/logger.h | 6 +++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/api/utils/logger/logger-impl.h b/src/api/utils/logger/logger-impl.h index e360c385c3..2f175ba172 100644 --- a/src/api/utils/logger/logger-impl.h +++ b/src/api/utils/logger/logger-impl.h @@ -23,6 +23,10 @@ #include #include +#ifndef LWNODE_EXPORT +#define LWNODE_EXPORT __attribute__((visibility("default"))) +#endif + class LogFormatter { public: std::string header(); @@ -154,7 +158,7 @@ class StdOut : public Logger::Output { using OutputInstantiator = std::function()>; -class LogOption { +class LWNODE_EXPORT LogOption { public: static void setDefaultOutputInstantiator(OutputInstantiator fn) { s_outputInstantiator_ = fn; @@ -166,8 +170,11 @@ class LogOption { static std::shared_ptr getDefalutOutput() { if (s_outputInstantiator_ == nullptr) { - // Set default output - s_outputInstantiator_ = []() { return std::make_shared(); }; + static std::shared_ptr default_output; + if (default_output == nullptr) { + default_output = std::make_shared(); + } + return default_output; } return s_outputInstantiator_(); } diff --git a/src/api/utils/logger/logger.h b/src/api/utils/logger/logger.h index 878c8f4e1c..70720bf1c7 100644 --- a/src/api/utils/logger/logger.h +++ b/src/api/utils/logger/logger.h @@ -78,12 +78,12 @@ struct DLogConfig : Logger::Output::Config { std::string tag; }; -class LWNodeLogger : public Logger { +class LWNODE_EXPORT LWNodeLogger : public Logger { public: LWNodeLogger(std::shared_ptr config) { outConfig_ = config; } }; -class DlogOut : public Logger::Output { +class LWNODE_EXPORT DlogOut : public Logger::Output { public: void flush(std::stringstream& ss, std::shared_ptr config = nullptr) override; @@ -91,7 +91,7 @@ class DlogOut : public Logger::Output { bool hasAutoAppendEndOfLine() override { return true; } }; -class LogKind { +class LWNODE_EXPORT LogKind { public: static std::shared_ptr user() { return getInstance()->user_; } static std::shared_ptr lwnode() { return getInstance()->lwnode_; }