Currently logging::Context is instantiated inside each translation unit separately
Signed-off-by: Vladimir Plazun <v.plazun@samsung.com>
class Context
{
public:
- Context() : _enabled{false}
+ Context() noexcept : _enabled{false}
{
const auto env = util::getConfigBool(util::config::NEURUN_LOG_ENABLE);
}
}
+ static Context &get() noexcept;
+
public:
bool enabled(void) const { return _enabled; }
bool _enabled;
};
-static Context ctx;
+static Context &ctx = Context::get();
} // namespace logging
} // namespace util
--- /dev/null
+#include "util/logging.h"
+
+neurun::util::logging::Context &neurun::util::logging::Context::get() noexcept
+{
+ static Context ctx;
+ return ctx;
+}