From: <man...@us...> - 2015-04-30 10:46:59
|
Revision: 5021 http://sourceforge.net/p/modplug/code/5021 Author: manxorist Date: 2015-04-30 10:46:52 +0000 (Thu, 30 Apr 2015) Log Message: ----------- [Ref] Deprecate the old printf based logging API. Resolve resulting warnings in soundlib/. [Ref] Reverse the order of logging levels. Higher numbers now correspond to more verbose logging. Modified Paths: -------------- trunk/OpenMPT/common/Logging.h trunk/OpenMPT/common/typedefs.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Reporting.cpp trunk/OpenMPT/soundlib/load_j2b.cpp trunk/OpenMPT/soundlib/plugins/DmoToVst.cpp trunk/OpenMPT/soundlib/tuning.cpp Modified: trunk/OpenMPT/common/Logging.h =================================================================== --- trunk/OpenMPT/common/Logging.h 2015-04-29 16:32:38 UTC (rev 5020) +++ trunk/OpenMPT/common/Logging.h 2015-04-30 10:46:52 UTC (rev 5021) @@ -15,11 +15,11 @@ enum LogLevel { - /*LogDebug = 1,*/ - LogNotification = 2, + LogDebug = 5, + LogNotification = 4, LogInformation = 3, - LogWarning = 4, - LogError = 5 + LogWarning = 2, + LogError = 1 }; @@ -31,6 +31,7 @@ case LogWarning: return MPT_USTRING("warning"); break; case LogInformation: return MPT_USTRING("info"); break; case LogNotification: return MPT_USTRING("notify"); break; + case LogDebug: return MPT_USTRING("debug"); break; } return MPT_USTRING("unknown"); } @@ -82,9 +83,9 @@ const Context &context; public: Logger(const Context &context) : context(context) {} - void MPT_PRINTF_FUNC(2,3) operator () (const char *format, ...); + MPT_DEPRECATED void MPT_PRINTF_FUNC(2,3) operator () (const char *format, ...); // migrate to type-safe version below, preferably to the one with loglevel + /* MPT_DEPRECATED */ void operator () (const AnyStringLocale &text); void operator () (LogLevel level, const mpt::ustring &text); - void operator () (const AnyStringLocale &text); }; #define Log mpt::log::Logger(MPT_LOG_CURRENTCONTEXT()) @@ -95,8 +96,8 @@ { public: inline void MPT_PRINTF_FUNC(2,3) operator () (const char * /*format*/, ...) {} + inline void operator () (const AnyStringLocale & /*text*/ ) {} inline void operator () (LogLevel /*level*/ , const mpt::ustring & /*text*/ ) {} - inline void operator () (const AnyStringLocale & /*text*/ ) {} }; #define Log if(true) {} else mpt::log::Logger() // completely compile out arguments to Log() so that they do not even get evaluated Modified: trunk/OpenMPT/common/typedefs.cpp =================================================================== --- trunk/OpenMPT/common/typedefs.cpp 2015-04-29 16:32:38 UTC (rev 5020) +++ trunk/OpenMPT/common/typedefs.cpp 2015-04-30 10:46:52 UTC (rev 5021) @@ -23,10 +23,14 @@ { if(msg) { - mpt::log::Logger(mpt::log::Context(file, line, function))("ASSERTION FAILED: %s (%s)", msg, expr); + mpt::log::Logger(mpt::log::Context(file, line, function))(LogError, + MPT_USTRING("ASSERTION FAILED: ") + mpt::ToUnicode(mpt::CharsetASCII, msg) + MPT_USTRING(" (") + mpt::ToUnicode(mpt::CharsetASCII, expr) + MPT_USTRING(")") + ); } else { - mpt::log::Logger(mpt::log::Context(file, line, function))("ASSERTION FAILED: %s", expr); + mpt::log::Logger(mpt::log::Context(file, line, function))(LogError, + MPT_USTRING("ASSERTION FAILED: ") + mpt::ToUnicode(mpt::CharsetASCII, expr) + ); } } Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2015-04-29 16:32:38 UTC (rev 5020) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2015-04-30 10:46:52 UTC (rev 5021) @@ -882,7 +882,10 @@ m_Log.push_back(LogEntry(level, text)); } else { - Reporting::Message(level, text); + if(level < LogDebug) + { + Reporting::Message(level, text); + } } } @@ -904,9 +907,10 @@ //-------------------------------------- { LogLevel retval = LogNotification; + // find the most severe loglevel for(std::vector<LogEntry>::const_iterator i=m_Log.begin(); i!=m_Log.end(); ++i) { - retval = std::max(retval, i->level); + retval = std::min(retval, i->level); } return retval; } @@ -932,10 +936,14 @@ if(!parent) parent = CMainFrame::GetMainFrame(); if(GetLog().size() > 0) { - std::wstring text = preamble + mpt::ToWide(GetLogString()); - std::wstring actualTitle = (title.length() == 0) ? MAINFRAME_TITLEW : title; - Reporting::Message(GetMaxLogLevel(), text, actualTitle, parent); - return IDOK; + LogLevel level = GetMaxLogLevel(); + if(level < LogDebug) + { + std::wstring text = preamble + mpt::ToWide(GetLogString()); + std::wstring actualTitle = (title.length() == 0) ? MAINFRAME_TITLEW : title; + Reporting::Message(level, text, actualTitle, parent); + return IDOK; + } } return IDCANCEL; } Modified: trunk/OpenMPT/mptrack/Reporting.cpp =================================================================== --- trunk/OpenMPT/mptrack/Reporting.cpp 2015-04-29 16:32:38 UTC (rev 5020) +++ trunk/OpenMPT/mptrack/Reporting.cpp 2015-04-30 10:46:52 UTC (rev 5021) @@ -47,6 +47,7 @@ result = GetTitle() + std::wstring(L" - "); switch(level) { + case LogDebug: result += L"Debug"; break; case LogNotification: result += L"Notification"; break; case LogInformation: result += L"Information"; break; case LogWarning: result += L"Warning"; break; Modified: trunk/OpenMPT/soundlib/load_j2b.cpp =================================================================== --- trunk/OpenMPT/soundlib/load_j2b.cpp 2015-04-29 16:32:38 UTC (rev 5020) +++ trunk/OpenMPT/soundlib/load_j2b.cpp 2015-04-30 10:46:52 UTC (rev 5021) @@ -659,7 +659,7 @@ } else { #ifdef DEBUG - Log("J2B: Unknown command: 0x%X, param 0x%X", m.command, m.param); + Log(mpt::String::Print("J2B: Unknown command: 0x%1, param 0x%2", mpt::fmt::HEX0<2>(m.command), mpt::fmt::HEX0<2>(m.param))); #endif // DEBUG m.command = CMD_NONE; } Modified: trunk/OpenMPT/soundlib/plugins/DmoToVst.cpp =================================================================== --- trunk/OpenMPT/soundlib/plugins/DmoToVst.cpp 2015-04-29 16:32:38 UTC (rev 5020) +++ trunk/OpenMPT/soundlib/plugins/DmoToVst.cpp 2015-04-30 10:46:52 UTC (rev 5021) @@ -297,7 +297,7 @@ || FAILED(m_pMediaObject->SetOutputType(0, &mt, 0))) { #ifdef DMO_LOG - Log("DMO: Failed to set I/O media type\n"); + Log(MPT_USTRING("DMO: Failed to set I/O media type")); #endif return -1; } @@ -543,11 +543,11 @@ return (p) ? p->GetEffect() : nullptr; } #ifdef DMO_LOG - Log("%s: Unable to use this DMO\n", lib.libraryName); + Log(lib.libraryName.ToUnicode() + MPT_USTRING(": Unable to use this DMO")); #endif } #ifdef DMO_LOG - else Log("%s: Failed to get IMediaObject & IMediaObjectInPlace interfaces\n", lib.libraryName); + else Log(lib.libraryName.ToUnicode() + MPT_USTRING(": Failed to get IMediaObject & IMediaObjectInPlace interfaces")); #endif if (pMO) pMO->Release(); if (pMOIP) pMOIP->Release(); Modified: trunk/OpenMPT/soundlib/tuning.cpp =================================================================== --- trunk/OpenMPT/soundlib/tuning.cpp 2015-04-29 16:32:38 UTC (rev 5020) +++ trunk/OpenMPT/soundlib/tuning.cpp 2015-04-30 10:46:52 UTC (rev 5021) @@ -406,12 +406,10 @@ if (pTuning->ProProcessUnserializationdata()) { #ifdef MODPLUG_TRACKER - Reporting::Error( + Reporting::Error(("Processing loaded data for tuning \"" + pTuning->GetName() + "\" failed.").c_str(), "Tuning load failure"); #else - Log("%s (%s)\n", + Log(LogError, MPT_USTRING("Processing loaded data for tuning \"") + mpt::ToUnicode(mpt::CharsetISO8859_1, pTuning->GetName()) + MPT_USTRING("\" failed.")); #endif - ("Processing loaded data for tuning \"" + pTuning->GetName() + "\" failed.").c_str(), "Tuning load failure" - ); delete pTuning; pTuning = nullptr; } else This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |