From da7388c9c8f875c4136b79c547e7663fe9bc41f7 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 4 Mar 2016 15:17:35 +0100 Subject: [PATCH] Make wxLogInfo() work even without wxLog::SetVerbose() It's confusing that wxLogInfo() and wxLogVerbose() are exactly the same and the former, and not only the latter, doesn't do anything unless SetVerbose() had been called, even if the log level is wxLOG_Info or higher. Fix this by checking for GetVerbose() in wxLogVerbose() only and making wxLogInfo() check the log level only. This makes it very similar to wxLogMessage() but this is not such a bad thing. Also improve wxLogVerbose() documentation. --- docs/changes.txt | 2 ++ include/wx/log.h | 9 ++++----- interface/wx/log.h | 28 +++++++++++++++++++++++++--- src/generic/logg.cpp | 1 - 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 0820cb4d17..f701982499 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -59,6 +59,8 @@ All: - Add support for the micro version (third component) to OS and toolkit version functions. See wxGetOsVersion(), wxPlatformInfo, and wxAppTraits. +- wxLogInfo() now logs messages if the log level is high enough, even without + wxLog::SetVerbose() which now only affects wxLogVerbose(). wxMSW: diff --git a/include/wx/log.h b/include/wx/log.h index 5775c14d72..cbc15efde9 100644 --- a/include/wx/log.h +++ b/include/wx/log.h @@ -1272,6 +1272,10 @@ WXDLLIMPEXP_BASE const wxChar* wxSysErrorMsg(unsigned long nErrCode = 0); #define wxLogMessage wxDO_LOG_IF_ENABLED(Message) #define wxVLogMessage(format, argptr) wxDO_LOGV(Message, format, argptr) +#define wxLogInfo wxDO_LOG_IF_ENABLED(Info) +#define wxVLogInfo(format, argptr) wxDO_LOGV(Info, format, argptr) + + // this one is special as it only logs if we're in verbose mode #define wxLogVerbose \ if ( !(wxLog::IsLevelEnabled(wxLOG_Info, wxLOG_COMPONENT) && \ @@ -1286,11 +1290,6 @@ WXDLLIMPEXP_BASE const wxChar* wxSysErrorMsg(unsigned long nErrCode = 0); else \ wxDO_LOGV(Info, format, argptr) -// deprecated synonyms for wxLogVerbose() and wxVLogVerbose() -#define wxLogInfo wxLogVerbose -#define wxVLogInfo wxVLogVerbose - - // another special case: the level is passed as first argument of the function // and so is not available to the macro // diff --git a/interface/wx/log.h b/interface/wx/log.h index 6eb75b7f22..d365548d54 100644 --- a/interface/wx/log.h +++ b/interface/wx/log.h @@ -1261,9 +1261,31 @@ void wxVLogMessage(const char* formatString, va_list argPtr); /** @addtogroup group_funcmacro_log */ //@{ /** - For verbose output. Normally, it is suppressed, but might be activated if - the user wishes to know more details about the program progress (another, - but possibly confusing name for the same function could be @c wxLogInfo). + For low priority messages. + + They are handled in the same way as messages logged by wxLogMessage() by + the default logger but could be handled differently by the custom loggers. + + @header{wx/log.h} +*/ +void wxLogInfo(const char* formatString, ... ); +void wxVLogInfo(const char* formatString, va_list argPtr); +//@} + +/** @addtogroup group_funcmacro_log */ +//@{ +/** + For verbose output. + + Messages generated by these functions are suppressed by default, even if + the log level is higher than ::wxLOG_Info and need to be explicitly + activated by calling wxLog::SetVerbose(). + + Notice that this is done automatically by wxWidgets, unless the standard + command line handling is overridden, if @c --verbose option is specified on + the program command line, so using these functions provides a simple way of + having some diagnostic messages not shown by default but which can be + easily shown by the user if needed. @header{wx/log.h} */ diff --git a/src/generic/logg.cpp b/src/generic/logg.cpp index e57f003b2b..36c832d389 100644 --- a/src/generic/logg.cpp +++ b/src/generic/logg.cpp @@ -341,7 +341,6 @@ void wxLogGui::DoLogRecord(wxLogLevel level, switch ( level ) { case wxLOG_Info: - if ( GetVerbose() ) case wxLOG_Message: { m_aMessages.Add(msg);