diff --git a/samples/webview/webview.cpp b/samples/webview/webview.cpp index f0aef9ab1c..0832a8445e 100644 --- a/samples/webview/webview.cpp +++ b/samples/webview/webview.cpp @@ -335,6 +335,24 @@ bool WebApp::OnInit() "

Page 1 was better.

"); wxMemoryFSHandler::AddFile("test.css", "h1 {color: red;}"); + // Set log target which only logs debugging messages in the usual way: all + // the rest will be shown in wxLogWindow created by WebFrame. + class DebugOnlyLog : public wxLog + { + public: + DebugOnlyLog() = default; + + protected: + void DoLogTextAtLevel(wxLogLevel level, const wxString& msg) override + { + // Ignore all non-debug/trace messages. + if ( level == wxLOG_Debug || level == wxLOG_Trace ) + wxLog::DoLogTextAtLevel(level, msg); + } + }; + + delete wxLog::SetActiveTarget(new DebugOnlyLog); + WebFrame *frame = new WebFrame(m_url); frame->Show(); @@ -412,7 +430,7 @@ WebFrame::WebFrame(const wxString& url, bool isMain, wxWebViewWindowFeatures* wi // Create a log window if (m_isMainFrame) - new wxLogWindow(this, _("Logging"), true, false); + new wxLogWindow(this, _("Logging")); #if wxUSE_WEBVIEW_EDGE // Check if a fixed version of edge is present in diff --git a/src/common/webview_chromium.cpp b/src/common/webview_chromium.cpp index 1372b8adab..51825cdec8 100644 --- a/src/common/webview_chromium.cpp +++ b/src/common/webview_chromium.cpp @@ -52,6 +52,15 @@ wxGCC_WARNING_RESTORE(unused-parameter) #error "Unsupported CEF version" #endif +namespace +{ + +constexpr const char* TRACE_CEF = "cef"; + +#define TRACE_CEF_FUNCTION() wxLogTrace(TRACE_CEF, "%s called", __FUNCTION__) + +} // anonymous namespace + extern WXDLLIMPEXP_DATA_WEBVIEW_CHROMIUM(const char) wxWebViewBackendChromium[] = "wxWebViewChromium"; int wxWebViewChromium::ms_activeWebViewCount = 0; @@ -769,6 +778,8 @@ bool ClientHandler::OnBeforePopup(CefRefPtr WXUNUSED(browser), void ClientHandler::OnAfterCreated(CefRefPtr browser) { + TRACE_CEF_FUNCTION(); + if ( !m_browser.get() ) { m_browser = browser; @@ -779,11 +790,15 @@ void ClientHandler::OnAfterCreated(CefRefPtr browser) } bool ClientHandler::DoClose(CefRefPtr WXUNUSED(browser)) { + TRACE_CEF_FUNCTION(); + return false; } void ClientHandler::OnBeforeClose(CefRefPtr browser) { + TRACE_CEF_FUNCTION(); + if ( browser->GetIdentifier() == m_browserId ) { m_browser = nullptr;