From: <man...@us...> - 2014-10-06 16:27:39
|
Revision: 4396 http://sourceforge.net/p/modplug/code/4396 Author: manxorist Date: 2014-10-06 16:27:26 +0000 (Mon, 06 Oct 2014) Log Message: ----------- [Ref] libopenmpt: Base the fallback of AddToLog on Log() instead of std::clog. This should really only be relevant during the constructor of CSoundFile (which in turn should not log), because libopenmpt always sets a custom logger shortly after constructing CSoundFile. For clarity, just handle all potential to-console log output in one single place in Logging.cpp . Modified Paths: -------------- trunk/OpenMPT/common/Logging.cpp trunk/OpenMPT/common/Logging.h trunk/OpenMPT/soundlib/Sndfile.cpp Modified: trunk/OpenMPT/common/Logging.cpp =================================================================== --- trunk/OpenMPT/common/Logging.cpp 2014-10-06 15:25:07 UTC (rev 4395) +++ trunk/OpenMPT/common/Logging.cpp 2014-10-06 16:27:26 UTC (rev 4396) @@ -168,6 +168,12 @@ } +void Logger::operator () (LogLevel level, const mpt::ustring &text) +//----------------------------------------------------------------- +{ + DoLog(context, LogLevelToString(level) + MPT_USTRING(": ") + text); +} + void Logger::operator () (const mpt::ustring &text) //------------------------------------------------- { Modified: trunk/OpenMPT/common/Logging.h =================================================================== --- trunk/OpenMPT/common/Logging.h 2014-10-06 15:25:07 UTC (rev 4395) +++ trunk/OpenMPT/common/Logging.h 2014-10-06 16:27:26 UTC (rev 4396) @@ -75,6 +75,7 @@ public: Logger(const Context &context) : context(context) {} void MPT_PRINTF_FUNC(2,3) operator () (const char *format, ...); + void operator () (LogLevel level, const mpt::ustring &text); void operator () (const mpt::ustring &text); void operator () (const std::string &text); #if MPT_WSTRING_CONVERT && !(MPT_USTRING_MODE_WIDE) @@ -92,6 +93,7 @@ { public: inline void MPT_PRINTF_FUNC(2,3) operator () (const char * /*format*/, ...) {} + inline void operator () (LogLevel /*level*/ , const mpt::ustring & /*text*/ ) {} inline void operator () (const mpt::ustring & /*text*/ ) {} inline void operator () (const std::string & /*text*/ ) {} #if MPT_WSTRING_CONVERT && !(MPT_USTRING_MODE_WIDE) Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2014-10-06 15:25:07 UTC (rev 4395) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2014-10-06 16:27:26 UTC (rev 4396) @@ -24,7 +24,6 @@ #include "tuningcollection.h" #include "../common/StringFixer.h" #include "FileReader.h" -#include <iostream> #include <sstream> #include <time.h> @@ -653,16 +652,20 @@ //---------------------------------------------------------------------- { if(m_pCustomLog) - return m_pCustomLog->AddToLog(level, text); - #ifdef MODPLUG_TRACKER - if(GetpModDoc()) GetpModDoc()->AddToLog(level, text); - #else - #ifdef MPT_WITH_CHARSET_LOCALE - std::clog << "openmpt: " << mpt::ToLocale(LogLevelToString(level)) << ": " << text << std::endl; + { + m_pCustomLog->AddToLog(level, text); + } else + { + #ifdef MODPLUG_TRACKER + if(GetpModDoc()) GetpModDoc()->AddToLog(level, text); #else - std::clog << "openmpt: " << mpt::ToCharset(mpt::CharsetUTF8, LogLevelToString(level)) << ": " << text << std::endl; + #ifdef MPT_WITH_CHARSET_LOCALE + Log(level, mpt::ToUnicode(mpt::CharsetLocale, text)); + #else + Log(level, mpt::ToUnicode(mpt::CharsetUTF8, text)); + #endif #endif - #endif + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |