| 2409 | } |
| 2410 | |
| 2411 | void CMainFrame::ProcessLog() |
| 2412 | { |
| 2413 | static const String pattern = _T("%Y-%m-%dT%H:%M:%S"); |
| 2414 | |
| 2415 | EnterCriticalSection(&m_cs); |
| 2416 | |
| 2417 | const bool bShow = std::any_of(m_logBuffer.begin(), m_logBuffer.end(), |
| 2418 | [](const auto& msg) { return msg.second; }); |
| 2419 | |
| 2420 | if (bShow && (m_wndOutputBar.m_hWnd == nullptr || !m_wndOutputBar.IsVisible())) |
| 2421 | ShowOutputPane(true); |
| 2422 | |
| 2423 | if (!m_pOutputDoc) |
| 2424 | m_pOutputDoc = static_cast<COutputDoc*>(theApp.GetOutputTemplate()->CreateNewDocument()); |
| 2425 | |
| 2426 | if (m_logging > 0 && !m_pLogChannel) |
| 2427 | { |
| 2428 | Poco::Channel::Ptr pSimpleFileChannel= new Poco::SimpleFileChannel( |
| 2429 | ucr::toUTF8(paths::ConcatPath(env::GetTemporaryPath(), _T("WinMerge.log")))); |
| 2430 | m_pLogChannel = new Poco::AsyncChannel(pSimpleFileChannel); |
| 2431 | } |
| 2432 | |
| 2433 | size_t size = 0; |
| 2434 | for (const auto& msg : m_logBuffer) |
| 2435 | size += msg.first->text.length() + 34; |
| 2436 | String text; |
| 2437 | text.reserve(size); |
| 2438 | for (const auto& msg : m_logBuffer) |
| 2439 | { |
| 2440 | const String logline = msg.first->format(pattern, true); |
| 2441 | text += logline + _T("\r\n"); |
| 2442 | if (m_logging > 0 && m_pLogChannel) |
| 2443 | { |
| 2444 | static const Poco::Message::Priority prio[] = { Poco::Message::PRIO_ERROR, Poco::Message::PRIO_WARNING, Poco::Message::PRIO_INFORMATION }; |
| 2445 | if (m_logging == 1 || (m_logging == 2 && msg.first->level <= Logger::LogLevel::WARN)) |
| 2446 | m_pLogChannel->log(Poco::Message("", ucr::toUTF8(logline), prio[static_cast<int>(msg.first->level)])); |
| 2447 | } |
| 2448 | delete msg.first; |
| 2449 | } |
| 2450 | m_logBuffer.clear(); |
| 2451 | |
| 2452 | LeaveCriticalSection(&m_cs); |
| 2453 | |
| 2454 | m_pOutputDoc->AppendLineWithAutoTrim(text); |
| 2455 | } |
| 2456 | |
| 2457 | /** |
| 2458 | * @brief Close all open windows. |
nothing calls this directly
no test coverage detected