From d7235ebb051593c83f280b5f4185cd6034647374 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 24 Mar 2021 17:29:30 +0100 Subject: [PATCH] Show states using names, not ordinals, in trace message This is much more readable. --- src/common/webrequest.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/common/webrequest.cpp b/src/common/webrequest.cpp index a604c89eb7..189b6d1c16 100644 --- a/src/common/webrequest.cpp +++ b/src/common/webrequest.cpp @@ -201,13 +201,34 @@ struct StateEventProcessor const wxString m_failMsg; }; +#if wxUSE_LOG_TRACE + +// Tiny helper to log states as strings rather than meaningless numbers. +wxString StateName(wxWebRequest::State state) +{ + switch ( state ) + { + case wxWebRequest::State_Idle: return wxS("IDLE"); + case wxWebRequest::State_Unauthorized: return wxS("UNAUTHORIZED"); + case wxWebRequest::State_Active: return wxS("ACTIVE"); + case wxWebRequest::State_Completed: return wxS("COMPLETED"); + case wxWebRequest::State_Failed: return wxS("FAILED"); + case wxWebRequest::State_Cancelled: return wxS("CANCELLED"); + } + + return wxString::Format("invalid state %d", state); +} + +#endif // wxUSE_LOG_TRACE + } // anonymous namespace void wxWebRequestImpl::SetState(wxWebRequest::State state, const wxString & failMsg) { wxCHECK_RET( state != m_state, "shouldn't switch to the same state" ); - wxLogTrace(wxTRACE_WEBREQUEST, "Request %p: state %d => %d", this, m_state, state); + wxLogTrace(wxTRACE_WEBREQUEST, "Request %p: state %s => %s", + this, StateName(m_state), StateName(state)); m_state = state;