X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/8bda633ffa7e6620b338829d69ab75445ff76605..8f46a826a07310dbd76e4b3a15f63ae055272542:/stglibs/logger.lib/include/stg/logger.h diff --git a/stglibs/logger.lib/include/stg/logger.h b/stglibs/logger.lib/include/stg/logger.h index 115d1fb3..60514f4a 100644 --- a/stglibs/logger.lib/include/stg/logger.h +++ b/stglibs/logger.lib/include/stg/logger.h @@ -1,17 +1,17 @@ #ifndef STG_LOGGER_H #define STG_LOGGER_H -#include - #include +#include + class STG_LOGGER; STG_LOGGER & GetStgLogger(); //----------------------------------------------------------------------------- class STG_LOGGER_LOCKER { public: - STG_LOGGER_LOCKER(pthread_mutex_t * m) : mutex(m) { pthread_mutex_lock(mutex); } + explicit STG_LOGGER_LOCKER(pthread_mutex_t * m) : mutex(m) { pthread_mutex_lock(mutex); } ~STG_LOGGER_LOCKER() { pthread_mutex_unlock(mutex); } private: @@ -44,18 +44,21 @@ private: mutable pthread_mutex_t mutex; }; //----------------------------------------------------------------------------- -class PLUGIN_LOGGER : private STG_LOGGER +class PLUGIN_LOGGER { -friend PLUGIN_LOGGER GetPluginLogger(const STG_LOGGER & logger, const std::string & pluginName); +friend PLUGIN_LOGGER GetPluginLogger(const STG_LOGGER& logger, const std::string& pluginName); public: - PLUGIN_LOGGER(const PLUGIN_LOGGER & rhs); - void operator()(const char * fmt, ...) const; - void operator()(const std::string & line) const; + PLUGIN_LOGGER(const PLUGIN_LOGGER& rhs) : m_parent(rhs.m_parent), m_pluginName(rhs.m_pluginName) {} // Need move here. + void operator()(const char* fmt, ...) const; + void operator()(const std::string& line) const; private: + PLUGIN_LOGGER& operator=(const PLUGIN_LOGGER&); // Copy assignment is prohibited. + PLUGIN_LOGGER(const STG_LOGGER & logger, const std::string & pn); - std::string pluginName; + const STG_LOGGER& m_parent; + std::string m_pluginName; }; PLUGIN_LOGGER GetPluginLogger(const STG_LOGGER & logger, const std::string & pluginName);