comparison Core/Logging.cpp @ 4004:9b5ace33a00d

cleaning SetErrorWarnInfoLoggingStreams()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 06 Jun 2020 11:14:10 +0200
parents 3c19371090c3
children 7f9909062d9c
comparison
equal deleted inserted replaced
4003:3c19371090c3 4004:9b5ace33a00d
839 { 839 {
840 loggingContext_->file_->flush(); 840 loggingContext_->file_->flush();
841 } 841 }
842 } 842 }
843 843
844 void SetErrorWarnInfoLoggingStreams(std::ostream* errorStream, 844 void SetErrorWarnInfoLoggingStreams(std::ostream& errorStream,
845 std::ostream* warningStream, 845 std::ostream& warningStream,
846 std::ostream* infoStream) 846 std::ostream& infoStream)
847 { 847 {
848 boost::mutex::scoped_lock lock(loggingMutex_);
849 std::unique_ptr<LoggingContext> old; 848 std::unique_ptr<LoggingContext> old;
850 849
850 {
851 boost::mutex::scoped_lock lock(loggingMutex_);
852
851 #if __cplusplus < 201103L 853 #if __cplusplus < 201103L
852 old.reset(loggingContext_.release()); 854 old.reset(loggingContext_.release());
853 #else 855 #else
854 old = std::move(loggingContext_); 856 old = std::move(loggingContext_);
855 #endif 857 #endif
856 858
857 loggingContext_.reset(new LoggingContext); 859 loggingContext_.reset(new LoggingContext);
858 loggingContext_->error_ = errorStream; 860 loggingContext_->error_ = &errorStream;
859 loggingContext_->warning_ = warningStream; 861 loggingContext_->warning_ = &warningStream;
860 loggingContext_->info_ = infoStream; 862 loggingContext_->info_ = &infoStream;
861 lock.unlock(); 863 }
864
862 EnableInfoLevel(old->infoEnabled_); 865 EnableInfoLevel(old->infoEnabled_);
863 EnableTraceLevel(old->traceEnabled_); 866 EnableTraceLevel(old->traceEnabled_);
864 } 867 }
865 868
866 #ifdef __EMSCRIPTEN__ 869 #ifdef __EMSCRIPTEN__