Skip to content

Commit 77e58d9

Browse files
committed
Add SetLogCallback() and GetLogCallback() functions (2)
1 parent 1471497 commit 77e58d9

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/WinWebDiffLib/WebWindow.hpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,7 +1569,7 @@ class CWebWindow
15691569
return path2;
15701570
}
15711571

1572-
static void WriteToErrorLog(const std::wstring& dirname, const std::wstring& url, HRESULT hr)
1572+
void WriteToErrorLog(const std::wstring& dirname, const std::wstring& url, HRESULT hr)
15731573
{
15741574
std::wstring msg;
15751575
LPTSTR errorText = nullptr;
@@ -1585,7 +1585,12 @@ class CWebWindow
15851585
std::filesystem::path path(dirname);
15861586
path /= L"[Error].log";
15871587
_wfopen_s(&fp, path.c_str(), L"at,ccs=UTF-8");
1588-
fwprintf(fp.get(), L"url=%s hr=%08x: %s", url.c_str(), hr, msg.c_str());
1588+
std::wstring text = L"url=" + url + L" hr=" + std::to_wstring(hr) + L": " + msg;
1589+
fwprintf(fp.get(), text.c_str());
1590+
1591+
auto logCallback = m_pDiffWindow->GetLogCallback();
1592+
if (logCallback)
1593+
logCallback(IWebDiffWindow::LogLevel::ERR, text.c_str());
15891594
}
15901595

15911596
static HRESULT WriteToTextFile(const std::wstring& path, const std::wstring& data)

0 commit comments

Comments
 (0)