void wxLogGui::Flush() { wxLog::Flush(); if ( !m_bHasMessages ) return; // do it right now to block any new calls to Flush() while we're here m_bHasMessages = false; // note that this must be done before examining m_aMessages as it may log // yet another message const unsigned repeatCount = LogLastRepeatIfNeeded(); const size_t nMsgCount = m_aMessages.size(); if ( repeatCount > 0 ) { m_aMessages[nMsgCount - 1] << " (" << m_aMessages[nMsgCount - 2] << ")"; } const wxString title = GetTitle(); const int style = GetSeverityIcon(); // avoid showing other log dialogs until we're done with the dialog we're // showing right now: nested modal dialogs make for really bad UI! Suspend(); // and ensure that we allow showing the log again afterwards, even if an // exception is thrown wxON_BLOCK_EXIT0(wxLog::Resume); if ( nMsgCount == 1 ) { // make a copy before calling Clear() const wxString message(m_aMessages[0]); Clear(); DoShowSingleLogMessage(message, title, style); } else // more than one message { wxArrayString messages; wxArrayInt severities; wxArrayLong times; messages.swap(m_aMessages); severities.swap(m_aSeverity); times.swap(m_aTimes); Clear(); DoShowMultipleLogMessages(messages, severities, times, title, style); } }
void wxLog::CallDoLogNow(wxLogLevel level, const wxString& msg, const wxLogRecordInfo& info) { if ( GetRepetitionCounting() ) { if ( msg == gs_prevLog.msg ) { gs_prevLog.numRepeated++; // nothing else to do, in particular, don't log the // repeated message return; } LogLastRepeatIfNeeded(); // reset repetition counter for a new message gs_prevLog.msg = msg; gs_prevLog.level = level; gs_prevLog.info = info; } // handle extra data which may be passed to us by wxLogXXX() wxString prefix, suffix; wxUIntPtr num = 0; if ( info.GetNumValue(wxLOG_KEY_SYS_ERROR_CODE, &num) ) { const long err = static_cast<long>(num); suffix.Printf(_(" (error %ld: %s)"), err, wxSysErrorMsg(err)); } #if wxUSE_LOG_TRACE wxString str; if ( level == wxLOG_Trace && info.GetStrValue(wxLOG_KEY_TRACE_MASK, &str) ) { prefix = "(" + str + ") "; } #endif // wxUSE_LOG_TRACE DoLogRecord(level, prefix + msg + suffix, info); }
void wxLog::Flush() { LogLastRepeatIfNeeded(); }