Index: ext/libicpf/src/log.cpp =================================================================== diff -u -N -re17c80d36eaa0430313e7d1058aa7a301d1510af -r01f412dddb725bcd82c0dce8755af7f113a101d8 --- ext/libicpf/src/log.cpp (.../log.cpp) (revision e17c80d36eaa0430313e7d1058aa7a301d1510af) +++ ext/libicpf/src/log.cpp (.../log.cpp) (revision 01f412dddb725bcd82c0dce8755af7f113a101d8) @@ -42,22 +42,34 @@ const char_t* __logtype_str[] = { "debug", "info", "warning", "error" }; /// Global variable initialized when constructing log_file object -log_file* __g_log=NULL; +static log_file* __g_log=NULL; -log_file::log_file() +/** Constructs a log_file object. + * \param[in] bGlobal - states if this should be treates as a global instance of the log_file. + * Only one global log_file instance could exist in the application. + */ +log_file::log_file(bool bGlobal) : + m_bGlobal(bGlobal), + m_pszPath(NULL), + m_bLogStd(false), + m_iLogLevel(LT_DEBUG) { - __g_log=this; - m_pszPath=NULL; - m_bLogStd=false; - m_iLogLevel=LT_DEBUG; + if (m_bGlobal) + { + assert(__g_log == NULL); // there is another instance of a global log running + __g_log=this; + } #ifdef WIN32 _fmode=_O_BINARY; #endif } +/** Standard destructor + */ log_file::~log_file() { - __g_log=NULL; + if (m_bGlobal) + __g_log=NULL; delete [] m_pszPath; } @@ -71,7 +83,7 @@ */ bool create_log(const char_t* pszPath, int_t iMaxSize, int_t iLogLevel, bool bLogStd, bool bClean) { - log_file* pLog=new log_file(); + log_file* pLog=new log_file(true); if (!pLog->init(pszPath, iMaxSize, iLogLevel, bLogStd, bClean)) { delete pLog;