LogViewer
A modern log viewer with AI-assisted analysis (Qt 6)
Loading...
Searching...
No Matches
NoopErrorPresenter.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "IErrorPresenter.hpp"
4#include "Logger.hpp"
5#include <mutex>
6#include <string_view>
7
8namespace ui {
9
14public:
15 bool CanShowDialogs() const noexcept override { return false; }
16
17 void ShowError(std::string_view message) override
18 {
19 std::lock_guard<std::mutex> lock(m_mutex);
20 if (!m_loggedOnce) {
22 "UI error presenter not configured; falling back to logs");
23 m_loggedOnce = true;
24 }
25 util::Logger::Error("{}", message);
26 }
27
28private:
29 mutable std::mutex m_mutex;
30 bool m_loggedOnce = false;
31};
32
33} // namespace ui
Logging facade for application-wide logging.
Presents user-facing error information via the current UI backend.
Definition IErrorPresenter.hpp:10
Logger-backed fallback when no concrete UI presenter is registered.
Definition NoopErrorPresenter.hpp:13
std::mutex m_mutex
Definition NoopErrorPresenter.hpp:29
void ShowError(std::string_view message) override
Display an error message to the user.
Definition NoopErrorPresenter.hpp:17
bool m_loggedOnce
Definition NoopErrorPresenter.hpp:30
bool CanShowDialogs() const noexcept override
Definition NoopErrorPresenter.hpp:15
static void Warn(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logger.hpp:297
static void Error(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logger.hpp:303
Definition IErrorPresenter.hpp:5