# HG changeset patch # User Alain Mazy # Date 1606129499 -3600 # Node ID 3c85edacd0eec822ee258a86b18a4abd41e699aa # Parent a691916ab535d44ee073e9a5cf98c25bababa502# Parent 7dc52763ab1ca52515110666c16fe185f646d493 merge diff -r 7dc52763ab1c -r 3c85edacd0ee OrthancFramework/Sources/Logging.cpp --- a/OrthancFramework/Sources/Logging.cpp Sat Nov 21 10:49:54 2020 +0100 +++ b/OrthancFramework/Sources/Logging.cpp Mon Nov 23 12:04:59 2020 +0100 @@ -40,6 +40,8 @@ static uint32_t infoCategoriesMask_ = 0; static uint32_t traceCategoriesMask_ = 0; + static std::string logTargetFolder_; // keep a track of the log folder in case of reset of the context + static std::string logTargetFile_; // keep a track of the log file in case of reset of the context const char* EnumerationToString(LogLevel level) { @@ -716,35 +718,24 @@ void Reset() { - // Recover the old logging context - std::unique_ptr old; + if (logTargetFile_.empty() && logTargetFolder_.empty()) + { + return; + } { boost::mutex::scoped_lock lock(loggingStreamsMutex_); - if (loggingStreamsContext_.get() == NULL) - { - return; - } - else - { -#if __cplusplus < 201103L - old.reset(loggingStreamsContext_.release()); -#else - old = std::move(loggingStreamsContext_); -#endif + loggingStreamsContext_.reset(new LoggingStreamsContext); + } - // Create a new logging context, - loggingStreamsContext_.reset(new LoggingStreamsContext); - } + // Recover the old logging context if any + if (!logTargetFile_.empty()) + { + SetTargetFile(logTargetFile_); } - - if (!old->targetFolder_.empty()) + else if (!logTargetFolder_.empty()) { - SetTargetFolder(old->targetFolder_); - } - else if (!old->targetFile_.empty()) - { - SetTargetFile(old->targetFile_); + SetTargetFolder(logTargetFolder_); } } @@ -762,6 +753,7 @@ loggingStreamsContext_->warning_ = loggingStreamsContext_->file_.get(); loggingStreamsContext_->error_ = loggingStreamsContext_->file_.get(); loggingStreamsContext_->info_ = loggingStreamsContext_->file_.get(); + logTargetFolder_ = path; } } @@ -780,6 +772,7 @@ loggingStreamsContext_->warning_ = loggingStreamsContext_->file_.get(); loggingStreamsContext_->error_ = loggingStreamsContext_->file_.get(); loggingStreamsContext_->info_ = loggingStreamsContext_->file_.get(); + logTargetFile_ = path; } }