From: <man...@us...> - 2015-06-15 16:30:27
|
Revision: 5319 http://sourceforge.net/p/modplug/code/5319 Author: manxorist Date: 2015-06-15 16:30:15 +0000 (Mon, 15 Jun 2015) Log Message: ----------- [Ref] Logging: Rename the type-safe log function from Log to the properly namespaced MPT_LOG. [Imp] Logging: In the default release OpenMPT build, always compile all logging statements and let the compiler optimize them away by dead code elimination. This avoids having Log() calls bitrot over time. Dead code elimination has been verified to work in this case. Bitrot happened for two reason: Log() has either been disabled at least in release builds or a per-file macro has been used which had been explicitely disabled due tue runtime cost. [Imp] Logging: In case the logging is not disabled and the logging level is not configured statically at build time, runtime configuration is now possible. The cost is a single inline conditional per discarded log message. Not even the actual message expression will get evaluated. [Imp] Logging: Add a coarse grained const char* facility parameter to MPT_LOG, which can be used for selective log filtering. Facility filtering has higher cost than level filtering but still not measurable compared to actually printing the message. [Imp] Logging: Add possibility to log to a newly allocated windows console window (disabled by default). [Imp] Logging: Add [Debug]LogLevel, [Debug]LogFacilitySolo, [Debug]LogFacilityBlocked, [Debug]LogFileEnable, [Debug]LogDebuggerEnable and [Debug]LogConsoleEnable hidden settings. [Ref] Logging: Un-deprecate the printf version for now. Causes too many warnings. [Ref] Logging: Flip LogInformation and LogNotification levels. This is a better match to the way the reporting message boxes get displayed (which is the current dominant LogLevel user). [Ref] Logging: Convert Log() to MPT_LOG() for those that broke during conversion. All the (currently disabled) per-file logging primitives as well as almost all Log() calls still need to get converted later though. [Doc] Logging: Roughly document how logging configuration and usage works. [Ref] Cleanup and remove the last remaining user of va_copy. Modified Paths: -------------- trunk/OpenMPT/common/BuildSettings.h trunk/OpenMPT/common/Logging.cpp trunk/OpenMPT/common/Logging.h trunk/OpenMPT/common/typedefs.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/TrackerSettings.h trunk/OpenMPT/sounddev/SoundDeviceBase.cpp trunk/OpenMPT/sounddev/SoundDeviceManager.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/tuning.cpp trunk/OpenMPT/test/test.cpp Modified: trunk/OpenMPT/common/BuildSettings.h =================================================================== --- trunk/OpenMPT/common/BuildSettings.h 2015-06-14 21:14:26 UTC (rev 5318) +++ trunk/OpenMPT/common/BuildSettings.h 2015-06-15 16:30:15 UTC (rev 5319) @@ -85,8 +85,10 @@ //#define MODPLUG_NO_FILESAVE // Disable any debug logging +//#define NO_LOGGING #ifndef _DEBUG -#define NO_LOGGING +#define MPT_LOG_GLOBAL_LEVEL_STATIC +#define MPT_LOG_GLOBAL_LEVEL 0 #endif // Disable all runtime asserts Modified: trunk/OpenMPT/common/Logging.cpp =================================================================== --- trunk/OpenMPT/common/Logging.cpp 2015-06-14 21:14:26 UTC (rev 5318) +++ trunk/OpenMPT/common/Logging.cpp 2015-06-15 16:30:15 UTC (rev 5319) @@ -1,7 +1,7 @@ /* * Logging.cpp * ----------- - * Purpose: General logging and user confirmation support + * Purpose: General logging * Notes : (currently none) * Authors: OpenMPT Devs * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. @@ -28,41 +28,103 @@ OPENMPT_NAMESPACE_BEGIN -//#define LOG_TO_FILE +namespace mpt +{ +namespace log +{ + +#ifndef NO_LOGGING -#if MPT_COMPILER_MSVC || (MPT_COMPILER_GCC && MPT_GCC_AT_LEAST(4,3,0) && MPT_GCC_BEFORE(4,4,0)) -#ifndef va_copy -#define va_copy(dst, src) MPT_DO { (dst) = (src); } MPT_WHILE_0 + + +#if !defined(MPT_LOG_GLOBAL_LEVEL_STATIC) +#if defined(MPT_LOG_GLOBAL_LEVEL) +int GlobalLogLevel = static_cast<int>(MPT_LOG_GLOBAL_LEVEL); +#else +int GlobalLogLevel = static_cast<int>(LogDebug); #endif #endif -namespace mpt -{ -namespace log -{ +#if defined(MODPLUG_TRACKER) && !defined(MPT_LOG_IS_DISABLED) -static const std::size_t LOGBUF_SIZE = 1024; +bool FileEnabled = false; +bool DebuggerEnabled = true; +bool ConsoleEnabled = false; +static char g_FacilitySolo[1024] = {0}; +static char g_FacilityBlocked[1024] = {0}; -#ifndef NO_LOGGING +void SetFacilities(const std::string &solo, const std::string &blocked) +{ + std::strcpy(g_FacilitySolo, solo.c_str()); + std::strcpy(g_FacilityBlocked, blocked.c_str()); +} +bool IsFacilityActive(const char *facility) +{ + if(facility) + { + if(std::strlen(g_FacilitySolo) > 0) + { + if(std::strcmp(facility, g_FacilitySolo) != 0) + { + return false; + } + } + if(std::strlen(g_FacilityBlocked) > 0) + { + if(std::strcmp(facility, g_FacilitySolo) == 0) + { + return false; + } + } + } + return true; +} -static MPT_NOINLINE void DoLog(const mpt::log::Context &context, mpt::ustring message) -//------------------------------------------------------------------------------------ +#endif + + +void Logger::SendLogMessage(const Context &context, LogLevel level, const char *facility, const mpt::ustring &text) +//----------------------------------------------------------------------------------------------------------------- { - // remove eol if already present - message = mpt::String::RTrim(message, MPT_USTRING("\r\n")); +#ifdef MPT_LOG_IS_DISABLED + MPT_UNREFERENCED_PARAMETER(context); + MPT_UNREFERENCED_PARAMETER(level); + MPT_UNREFERENCED_PARAMETER(facility); + MPT_UNREFERENCED_PARAMETER(text); +#else // !MPT_LOG_IS_DISABLED + MPT_MAYBE_CONSTANT_IF(mpt::log::GlobalLogLevel < level) + { + return; + } #if defined(MODPLUG_TRACKER) + if(!IsFacilityActive(facility)) + { + return; + } + #else // !MODPLUG_TRACKER + MPT_UNREFERENCED_PARAMETER(facility); + #endif // MODPLUG_TRACKER + // remove eol if already present and add log level prefix + const mpt::ustring message = LogLevelToString(level) + MPT_USTRING(": ") + mpt::String::RTrim(text, MPT_USTRING("\r\n")); + const mpt::ustring file = mpt::ToUnicode(mpt::CharsetASCII, context.file); + const mpt::ustring function = mpt::ToUnicode(mpt::CharsetASCII, context.function); + const mpt::ustring line = mpt::ufmt::dec(context.line); + #if defined(MODPLUG_TRACKER) #if MPT_OS_WINDOWS static uint64 s_lastlogtime = 0; uint64 cur = mpt::Date::ANSI::Now(); uint64 diff = cur/10000 - s_lastlogtime; s_lastlogtime = cur/10000; +#else + uint64 cur = 0; + uint64 diff = 0; #endif - #ifdef LOG_TO_FILE + if(mpt::log::FileEnabled) { static FILE * s_logfile = nullptr; if(!s_logfile) @@ -71,78 +133,77 @@ } if(s_logfile) { - fprintf(s_logfile, mpt::ToCharset(mpt::CharsetUTF8, mpt::String::Print(MPT_USTRING("%1+%2 %3(%4): %5 [%6]\n" -#if MPT_OS_WINDOWS + fprintf(s_logfile, mpt::ToCharset(mpt::CharsetUTF8, MPT_UFORMAT("%1+%2 %3(%4): %5 [%6]\n" , mpt::Date::ANSI::ToString(cur) , mpt::ufmt::dec<6>(diff) -#else - , 0 - , 0 -#endif - , mpt::ToUnicode(mpt::CharsetASCII, context.file) - , context.line + , file + , line , message - , mpt::ToUnicode(mpt::CharsetASCII, context.function) - ))).c_str()); + , function + )).c_str()); fflush(s_logfile); } } - #endif // LOG_TO_FILE + if(mpt::log::DebuggerEnabled) { - OutputDebugStringW(mpt::String::Print(L"%1(%2): +%3 %4 [%5]\n" - , mpt::ToWide(mpt::CharsetASCII, context.file) - , context.line - , mpt::wfmt::dec<6>(diff) + OutputDebugStringW(mpt::ToWide(MPT_UFORMAT("%1(%2): +%3 %4 [%5]\n" + , file + , line + , mpt::ufmt::dec<6>(diff) , message - , mpt::ToWide(mpt::CharsetASCII, context.function) - ).c_str()); + , function + )).c_str()); } + if(mpt::log::ConsoleEnabled) + { + static bool consoleInited = false; + if(!consoleInited) + { + AllocConsole(); + consoleInited = true; + } + std::wstring consoletext = mpt::ToWide(message); + DWORD dummy = 0; + WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), consoletext.c_str(), consoletext.length(), &dummy, NULL); + } #else // !MODPLUG_TRACKER std::clog - << "openmpt: " - << context.file << "(" << context.line << ")" << ": " + << "libopenmpt: " + << mpt::ToCharset(mpt::CharsetLocaleOrUTF8, file) << "(" << mpt::ToCharset(mpt::CharsetLocaleOrUTF8, line) << ")" << ": " << mpt::ToCharset(mpt::CharsetLocaleOrUTF8, message) - << " [" << context.function << "]" + << " [" << mpt::ToCharset(mpt::CharsetLocaleOrUTF8, function) << "]" << std::endl; #endif // MODPLUG_TRACKER +#endif // MPT_LOG_IS_DISABLED } +void LegacyLogger::operator () (const AnyStringLocale &text) +//---------------------------------------------------------- +{ + SendLogMessage(context, MPT_LEGACY_LOGLEVEL, "", text); +} -static MPT_NOINLINE void DoLog(const mpt::log::Context &context, const char *format, va_list args) -//------------------------------------------------------------------------------------------------ +void LegacyLogger::operator () (const char *format, ...) +//------------------------------------------------------ { + static const std::size_t LOGBUF_SIZE = 1024; char message[LOGBUF_SIZE]; va_list va; - va_copy(va, args); + va_start(va, format); vsnprintf(message, LOGBUF_SIZE, format, va); + va_end(va); message[LOGBUF_SIZE - 1] = '\0'; - va_end(va); - DoLog(context, mpt::ToUnicode(mpt::CharsetLocaleOrUTF8, message)); + SendLogMessage(context, MPT_LEGACY_LOGLEVEL, "", mpt::ToUnicode(mpt::CharsetLocaleOrUTF8, message)); } - -void Logger::operator () (LogLevel level, const mpt::ustring &text) -//----------------------------------------------------------------- +void LegacyLogger::operator () (LogLevel level, const mpt::ustring &text) +//----------------------------------------------------------------------- { - DoLog(context, LogLevelToString(level) + MPT_USTRING(": ") + text); + SendLogMessage(context, level, "", text); } -void Logger::operator () (const AnyStringLocale &text) -//---------------------------------------------------- -{ - DoLog(context, text); -} -void Logger::operator () (const char *format, ...) -//------------------------------------------------ -{ - va_list va; - va_start(va, format); - DoLog(context, format, va); - va_end(va); -} - #endif // !NO_LOGGING Modified: trunk/OpenMPT/common/Logging.h =================================================================== --- trunk/OpenMPT/common/Logging.h 2015-06-14 21:14:26 UTC (rev 5318) +++ trunk/OpenMPT/common/Logging.h 2015-06-15 16:30:15 UTC (rev 5319) @@ -1,7 +1,7 @@ /* * Logging.h * --------- - * Purpose: General logging and user confirmation support + * Purpose: General logging * Notes : (currently none) * Authors: OpenMPT Devs * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. @@ -13,11 +13,56 @@ OPENMPT_NAMESPACE_BEGIN +/* + + +Build time logging configuration (in BuildSettings.h): + + * #define NO_LOGGING + Disables all logging completely. + MPT_LOG calls are not even compiled but instead completely removed via the + preprocessor. + + * #define MPT_LOG_GLOBAL_LEVEL_STATIC + #define MPT_LOG_GLOBAL_LEVEL # + Define the former (to anything) and the latter (to one of the log levels + below) in order to statically select the verbosity of logging at build time. + MPT_LOG calls that exceed the specified logging level will get dead-code + eliminated at compile time. + This especially means that, when setting MPT_LOG_GLOBAL_LEVEL to 0, no + MPT_LOG call (with a constant level parameter) remains in the resulting + binary, however, they still do get parsed and properly type checked by the + compiler. + + +Logging: + +If the context is related to a particular CSoundfile instance, use +CSoundfile::AddToLog. + +Logging a simple message: +MPT_LOG(LogWarning, "sounddev", "some message"); +MPT_LOG(LogWarning, "sounddev", MPT_USTRING("some message")); +Facility is some course grained code section identifier (more coarse grained +than the current file name probably), useful to do some selective logging. + +Logging a more complex message: +MPT_LOG(LogWarning, "sounddev", MPT_UFORMAT("Some message: foo=%1, bar=0x%2", foo, mpt::ufmt::hex0<8>(bar))); + +Note that even with full enabled logging and a runtime configurable logging +level, the runtime overhead of a MPT_LOG(level, facility, text) call is just a +single conditional in case the verbosity does not require logging the respective +message. Even the expression "text" is not evaluated. + + +*/ + + enum LogLevel { LogDebug = 5, - LogNotification = 4, - LogInformation = 3, + LogInformation = 4, + LogNotification = 3, LogWarning = 2, LogError = 1 }; @@ -29,8 +74,8 @@ { case LogError: return MPT_USTRING("error"); break; case LogWarning: return MPT_USTRING("warning"); break; + case LogNotification: return MPT_USTRING("notify"); 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"); @@ -53,6 +98,36 @@ { + +#ifndef NO_LOGGING + + +#if defined(MPT_LOG_GLOBAL_LEVEL_STATIC) +#if (MPT_LOG_GLOBAL_LEVEL <= 0) +// Logging framework is enabled (!NO_LOGGING) but all logging has beeen statically disabled. +// All logging code gets compiled and immediately dead-code eliminated. +#define MPT_LOG_IS_DISABLED +#endif +static const int GlobalLogLevel = MPT_LOG_GLOBAL_LEVEL ; +#else +extern int GlobalLogLevel; +#endif + + +#if defined(MODPLUG_TRACKER) && !defined(MPT_LOG_IS_DISABLED) +extern bool FileEnabled; +extern bool DebuggerEnabled; +extern bool ConsoleEnabled; +void SetFacilities(const std::string &solo, const std::string &blocked); +bool IsFacilityActive(const char *facility); +#else +static forceinline bool IsFacilityActive(const char * /*facility*/ ) { return true; } +#endif + + +#endif // !NO_LOGGING + + struct Context { const char * const file; @@ -79,35 +154,67 @@ #ifndef NO_LOGGING + class Logger { +public: + // facility:ASCII + void SendLogMessage(const Context &context, LogLevel level, const char *facility, const mpt::ustring &text); +public: + // facility:ASCII, text:ASCII (only string literals) + template <std::size_t size> forceinline void SendLogMessage(const Context &context, LogLevel level, const char *facility, const char (&text)[size]) + { + SendLogMessage(context, level, facility, mpt::ToUnicode(mpt::CharsetASCII, text)); + } +}; + +#define MPT_LOG(level, facility, text) \ + MPT_DO \ + { \ + MPT_MAYBE_CONSTANT_IF(mpt::log::GlobalLogLevel >= ( level )) \ + { \ + MPT_MAYBE_CONSTANT_IF(mpt::log::IsFacilityActive(( facility ))) \ + { \ + mpt::log::Logger().SendLogMessage( MPT_LOG_CURRENTCONTEXT() , ( level ), ( facility ), ( text )); \ + } \ + } \ + } MPT_WHILE_0 \ +/**/ + + +#define MPT_LEGACY_LOGLEVEL LogDebug + +class LegacyLogger : public Logger +{ private: - const Context &context; + const Context context; public: - Logger(const Context &context) : context(context) {} - 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); + LegacyLogger(const Context &context) : context(context) {} + /* MPT_DEPRECATED */ void MPT_PRINTF_FUNC(2,3) operator () (const char *format, ...); // migrate to type-safe MPT_LOG + /* MPT_DEPRECATED */ void operator () (const AnyStringLocale &text); // migrate to properly namespaced MPT_LOG + /* MPT_DEPRECATED */ void operator () (LogLevel level, const mpt::ustring &text); // migrate to properly namespaced MPT_LOG }; -#define Log mpt::log::Logger(MPT_LOG_CURRENTCONTEXT()) +#define Log MPT_MAYBE_CONSTANT_IF(mpt::log::GlobalLogLevel < MPT_LEGACY_LOGLEVEL) { } else MPT_MAYBE_CONSTANT_IF(!mpt::log::IsFacilityActive("")) { } else mpt::log::LegacyLogger(MPT_LOG_CURRENTCONTEXT()) + #else // !NO_LOGGING -class Logger + +#define MPT_LOG(level, facility, text) MPT_DO { } MPT_WHILE_0 + +struct LegacyLogger { -public: - inline void MPT_PRINTF_FUNC(2,3) operator () (const char * /*format*/, ...) {} + 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*/ ) {} }; +#define Log MPT_CONSTANT_IF(true) {} else mpt::log::LegacyLogger() // completely compile out arguments to Log() so that they do not even get evaluated -#define Log if(true) {} else mpt::log::Logger() // completely compile out arguments to Log() so that they do not even get evaluated #endif // NO_LOGGING - #if defined(MODPLUG_TRACKER) && MPT_OS_WINDOWS namespace Trace { Modified: trunk/OpenMPT/common/typedefs.cpp =================================================================== --- trunk/OpenMPT/common/typedefs.cpp 2015-06-14 21:14:26 UTC (rev 5318) +++ trunk/OpenMPT/common/typedefs.cpp 2015-06-15 16:30:15 UTC (rev 5319) @@ -23,12 +23,12 @@ { if(msg) { - mpt::log::Logger(mpt::log::Context(file, line, function))(LogError, + mpt::log::Logger().SendLogMessage(mpt::log::Context(file, line, function), LogError, "ASSERT", 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))(LogError, + mpt::log::Logger().SendLogMessage(mpt::log::Context(file, line, function), LogError, "ASSERT", MPT_USTRING("ASSERTION FAILED: ") + mpt::ToUnicode(mpt::CharsetASCII, expr) ); } Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2015-06-14 21:14:26 UTC (rev 5318) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2015-06-15 16:30:15 UTC (rev 5319) @@ -909,7 +909,7 @@ LogLevel CModDoc::GetMaxLogLevel() const //-------------------------------------- { - LogLevel retval = LogNotification; + LogLevel retval = LogInformation; // find the most severe loglevel for(std::vector<LogEntry>::const_iterator i=m_Log.begin(); i!=m_Log.end(); ++i) { Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2015-06-14 21:14:26 UTC (rev 5318) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2015-06-15 16:30:15 UTC (rev 5319) @@ -911,7 +911,7 @@ mpt::Windows::Version::Init(); mpt::String::InitCharsets(); - Log("OpenMPT Start"); + MPT_LOG(LogInformation, "", MPT_USTRING("OpenMPT Start")); ASSERT(nullptr == m_pDocManager); m_pDocManager = new CModDocManager(); @@ -934,6 +934,23 @@ m_pSettings = new SettingsContainer(m_pSettingsIniFile); m_pTrackerSettings = new TrackerSettings(*m_pSettings); + // enable debug features (as early as possible after reading the settings) + #if !defined(NO_LOGGING) && !defined(MPT_LOG_IS_DISABLED) + #if !defined(MPT_LOG_GLOBAL_LEVEL_STATIC) + mpt::log::GlobalLogLevel = TrackerSettings::Instance().DebugLogLevel; + #endif + mpt::log::SetFacilities(TrackerSettings::Instance().DebugLogFacilitySolo, TrackerSettings::Instance().DebugLogFacilityBlocked); + mpt::log::FileEnabled = TrackerSettings::Instance().DebugLogFileEnable; + mpt::log::DebuggerEnabled = TrackerSettings::Instance().DebugLogDebuggerEnable; + mpt::log::ConsoleEnabled = TrackerSettings::Instance().DebugLogConsoleEnable; + #endif + MPT_LOG(LogInformation, "", MPT_USTRING("OpenMPT settings initialized.")); + if(TrackerSettings::Instance().DebugTraceEnable) + { + mpt::log::Trace::Enable(TrackerSettings::Instance().DebugTraceSize); + } + MPT_TRACE(); + // Create missing diretories if(!TrackerSettings::Instance().PathTunings.GetDefaultDir().IsDirectory()) { @@ -943,13 +960,6 @@ m_pSongSettingsIniFile = new IniFileSettingsBackend(m_szConfigDirectory + MPT_PATHSTRING("SongSettings.ini")); m_pSongSettings = new SettingsContainer(m_pSongSettingsIniFile); - // enable debug features (as early as possible after reading the settings) - if(TrackerSettings::Instance().DebugTraceEnable) - { - mpt::log::Trace::Enable(TrackerSettings::Instance().DebugTraceSize); - } - MPT_TRACE(); - m_pComponentManagerSettings = new ComponentManagerSettings(TrackerSettings::Instance()); m_pPluginCache = new IniFileSettingsContainer(m_szPluginCacheFileName); Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2015-06-14 21:14:26 UTC (rev 5318) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2015-06-15 16:30:15 UTC (rev 5319) @@ -261,6 +261,14 @@ , UpdateSendGUID(conf, "Update", "SendGUID", CUpdateCheck::GetSendGUID()) , UpdateShowUpdateHint(conf, "Update", "ShowUpdateHint", CUpdateCheck::GetShowUpdateHint()) // Debug +#if !defined(NO_LOGGING) && !defined(MPT_LOG_IS_DISABLED) + , DebugLogLevel(conf, "Debug", "LogLevel", static_cast<int>(mpt::log::GlobalLogLevel)) + , DebugLogFacilitySolo(conf, "Debug", "LogFacilitySolo", std::string()) + , DebugLogFacilityBlocked(conf, "Debug", "LogFacilityBlocked", std::string()) + , DebugLogFileEnable(conf, "Debug", "LogFileEnable", mpt::log::FileEnabled) + , DebugLogDebuggerEnable(conf, "Debug", "LogDebuggerEnable", mpt::log::DebuggerEnabled) + , DebugLogConsoleEnable(conf, "Debug", "LogConsoleEnable", mpt::log::ConsoleEnabled) +#endif , DebugTraceEnable(conf, "Debug", "TraceEnable", false) , DebugTraceSize(conf, "Debug", "TraceSize", 1000000) , DebugTraceAlwaysDump(conf, "Debug", "TraceAlwaysDump", false) Modified: trunk/OpenMPT/mptrack/TrackerSettings.h =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.h 2015-06-14 21:14:26 UTC (rev 5318) +++ trunk/OpenMPT/mptrack/TrackerSettings.h 2015-06-15 16:30:15 UTC (rev 5319) @@ -11,6 +11,8 @@ #pragma once +#include "../common/Logging.h" +#include "../common/version.h" #include "../soundlib/MixerSettings.h" #include "../soundlib/Resampler.h" #include "../soundlib/SampleFormat.h" @@ -19,7 +21,6 @@ #include "../sounddsp/Reverb.h" #include "../sounddev/SoundDevice.h" #include "StreamEncoder.h" -#include "../common/version.h" #include "Settings.h" #include <bitset> @@ -644,6 +645,15 @@ // Debug +#if !defined(NO_LOGGING) && !defined(MPT_LOG_IS_DISABLED) + Setting<int> DebugLogLevel; + Setting<std::string> DebugLogFacilitySolo; + Setting<std::string> DebugLogFacilityBlocked; + Setting<bool> DebugLogFileEnable; + Setting<bool> DebugLogDebuggerEnable; + Setting<bool> DebugLogConsoleEnable; +#endif + Setting<bool> DebugTraceEnable; Setting<uint32> DebugTraceSize; Setting<bool> DebugTraceAlwaysDump; Modified: trunk/OpenMPT/sounddev/SoundDeviceBase.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceBase.cpp 2015-06-14 21:14:26 UTC (rev 5318) +++ trunk/OpenMPT/sounddev/SoundDeviceBase.cpp 2015-06-15 16:30:15 UTC (rev 5319) @@ -219,7 +219,7 @@ //------------------------------------------------------------------- { MPT_TRACE(); - Log(level, str); + MPT_LOG(level, "sounddev", str); if(m_MessageReceiver) { m_MessageReceiver->SoundDeviceMessage(level, str); Modified: trunk/OpenMPT/sounddev/SoundDeviceManager.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceManager.cpp 2015-06-14 21:14:26 UTC (rev 5318) +++ trunk/OpenMPT/sounddev/SoundDeviceManager.cpp 2015-06-15 16:30:15 UTC (rev 5319) @@ -153,14 +153,14 @@ } std::stable_sort(m_SoundDevices.begin(), m_SoundDevices.end(), CompareInfo(typePriorities)); - Log(LogDebug, MPT_USTRING("Sound Devices enumerated:")); + MPT_LOG(LogDebug, "sounddev", MPT_USTRING("Sound Devices enumerated:")); for(std::size_t i = 0; i < m_SoundDevices.size(); ++i) { - Log(LogDebug, mpt::String::Print(MPT_USTRING(" Identifier : %1"), m_SoundDevices[i].GetIdentifier())); - Log(LogDebug, mpt::String::Print(MPT_USTRING(" Type : %1"), m_SoundDevices[i].type)); - Log(LogDebug, mpt::String::Print(MPT_USTRING(" InternalID: %1"), m_SoundDevices[i].internalID)); - Log(LogDebug, mpt::String::Print(MPT_USTRING(" API Name : %1"), m_SoundDevices[i].apiName)); - Log(LogDebug, mpt::String::Print(MPT_USTRING(" Name : %1"), m_SoundDevices[i].name)); + MPT_LOG(LogDebug, "sounddev", MPT_UFORMAT(" Identifier : %1", m_SoundDevices[i].GetIdentifier())); + MPT_LOG(LogDebug, "sounddev", MPT_UFORMAT(" Type : %1", m_SoundDevices[i].type)); + MPT_LOG(LogDebug, "sounddev", MPT_UFORMAT(" InternalID: %1", m_SoundDevices[i].internalID)); + MPT_LOG(LogDebug, "sounddev", MPT_UFORMAT(" API Name : %1", m_SoundDevices[i].apiName)); + MPT_LOG(LogDebug, "sounddev", MPT_UFORMAT(" Name : %1", m_SoundDevices[i].name)); for(std::map<mpt::ustring, mpt::ustring>::const_iterator extraIt = m_SoundDevices[i].extraData.begin(); extraIt != m_SoundDevices[i].extraData.end(); ++extraIt) { Log(LogDebug, mpt::String::Print(MPT_USTRING(" Extra Data: %1 = %2"), extraIt->first, extraIt->second)); Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2015-06-14 21:14:26 UTC (rev 5318) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2015-06-15 16:30:15 UTC (rev 5319) @@ -153,7 +153,7 @@ #ifdef MODPLUG_TRACKER if(GetpModDoc()) GetpModDoc()->AddToLog(level, text); #else - Log(level, text); + MPT_LOG(level, "soundlib", text); #endif } } Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2015-06-14 21:14:26 UTC (rev 5318) +++ trunk/OpenMPT/soundlib/Sndfile.h 2015-06-15 16:30:15 UTC (rev 5319) @@ -555,7 +555,7 @@ TimingInfo m_TimingInfo; // only valid if !m_bIsRendering private: - // logging and user interaction + // logging ILog *m_pCustomLog; public: @@ -563,10 +563,10 @@ ~CSoundFile(); public: - // logging and user interaction + // logging void SetCustomLog(ILog *pLog) { m_pCustomLog = pLog; } void AddToLog(LogLevel level, const mpt::ustring &text) const; - /*MPT_DEPRECATED*/ void AddToLog(const std::string &text) const { AddToLog(LogInformation, mpt::ToUnicode(mpt::CharsetLocaleOrUTF8, text)); } + /*MPT_DEPRECATED*/ void AddToLog(const AnyStringLocale &text) const { AddToLog(LogInformation, mpt::ToUnicode(text)); } public: Modified: trunk/OpenMPT/soundlib/tuning.cpp =================================================================== --- trunk/OpenMPT/soundlib/tuning.cpp 2015-06-14 21:14:26 UTC (rev 5318) +++ trunk/OpenMPT/soundlib/tuning.cpp 2015-06-15 16:30:15 UTC (rev 5319) @@ -414,7 +414,7 @@ #ifdef MODPLUG_TRACKER Reporting::Error(("Processing loaded data for tuning \"" + pTuning->GetName() + "\" failed.").c_str(), "Tuning load failure"); #else - Log(LogError, MPT_USTRING("Processing loaded data for tuning \"") + mpt::ToUnicode(mpt::CharsetISO8859_1, pTuning->GetName()) + MPT_USTRING("\" failed.")); + MPT_LOG(LogError, "tuning", MPT_USTRING("Processing loaded data for tuning \"") + mpt::ToUnicode(mpt::CharsetISO8859_1, pTuning->GetName()) + MPT_USTRING("\" failed.")); #endif delete pTuning; pTuning = nullptr; } Modified: trunk/OpenMPT/test/test.cpp =================================================================== --- trunk/OpenMPT/test/test.cpp 2015-06-14 21:14:26 UTC (rev 5318) +++ trunk/OpenMPT/test/test.cpp 2015-06-15 16:30:15 UTC (rev 5319) @@ -503,6 +503,7 @@ VERIFY_EQUAL(MPT_FORMAT("%b", "a"), "%b"); #if defined(_MFC_VER) + VERIFY_EQUAL(mpt::ToUString(CString(_T("foobar"))), MPT_USTRING("foobar")); VERIFY_EQUAL(MPT_TFORMAT("%1%2%3",1,2,3), _T("123")); VERIFY_EQUAL(MPT_TFORMAT("%1%2%3",1,mpt::tfmt::dec0<3>(2),3), _T("10023")); #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |