mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 01:05:34 +08:00
refs #338 Using CLogPattern for subscribing to log messages and selectively enabling console output.
This commit is contained in:
@@ -169,18 +169,18 @@ namespace BlackMiscTest
|
||||
}
|
||||
else
|
||||
{
|
||||
QString category;
|
||||
if (line.startsWith("app")) category = CLogCategoryList(applicationContext).back().toQString();
|
||||
else if (line.startsWith("aud")) category = CLogCategoryList(audioContext).back().toQString();
|
||||
else if (line.startsWith("net")) category = CLogCategoryList(networkContext).back().toQString();
|
||||
else if (line.startsWith("own")) category = CLogCategoryList(ownAircraftContext).back().toQString();
|
||||
else if (line.startsWith("set")) category = CLogCategoryList(settingsContext).back().toQString();
|
||||
else if (line.startsWith("sim")) category = CLogCategoryList(simulatorContext).back().toQString();
|
||||
if (! category.isEmpty())
|
||||
CLogCategoryList categories;
|
||||
if (line.startsWith("app")) categories = applicationContext;
|
||||
else if (line.startsWith("aud")) categories = audioContext;
|
||||
else if (line.startsWith("net")) categories = networkContext;
|
||||
else if (line.startsWith("own")) categories = ownAircraftContext;
|
||||
else if (line.startsWith("set")) categories = settingsContext;
|
||||
else if (line.startsWith("sim")) categories = simulatorContext;
|
||||
if (! categories.isEmpty())
|
||||
{
|
||||
BlackMisc::singleShot(0, BlackMisc::CLogHandler::instance()->thread(), [ = ]()
|
||||
{
|
||||
BlackMisc::CLogHandler::instance()->handlerForCategoryPrefix(category)->enableConsoleOutput(enable);
|
||||
BlackMisc::CLogHandler::instance()->handlerForPattern(CLogPattern::allOf(categories))->enableConsoleOutput(enable);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -298,7 +298,6 @@ bool MainWindow::isContextAudioAvailableCheck()
|
||||
void MainWindow::ps_displayStatusMessageInGui(const CStatusMessage &statusMessage)
|
||||
{
|
||||
if (statusMessage.isRedundant()) return;
|
||||
if (statusMessage.getSeverity() == CStatusMessage::SeverityDebug) return;
|
||||
|
||||
if (statusMessage.wasHandledBy(this)) return;
|
||||
statusMessage.markAsHandledBy(this);
|
||||
@@ -313,7 +312,6 @@ void MainWindow::ps_displayStatusMessageInGui(const CStatusMessage &statusMessag
|
||||
this->ui->comp_MainInfoArea->getLogComponent()->appendStatusMessageToList(statusMessage);
|
||||
|
||||
// display overlay for errors, but not for validation
|
||||
// TODO smarter use of CLogCategoryHandler to dispatch different categories of message to different MainWindow slots
|
||||
if (statusMessage.getSeverity() == CStatusMessage::SeverityError && ! statusMessage.getCategories().contains(CLogCategory::validation()))
|
||||
{
|
||||
this->m_compInfoWindow->displayStatusMessage(statusMessage);
|
||||
|
||||
@@ -112,8 +112,8 @@ void MainWindow::init(const CRuntimeConfig &runtimeConfig)
|
||||
this->connect(this->ui->comp_MainInfoArea->getSettingsComponent(), &CSettingsComponent::changedAtcStationsUpdateInterval, this->ui->comp_MainInfoArea->getAtcStationComponent(), &::CAtcStationComponent::setUpdateIntervalSeconds);
|
||||
|
||||
// log messages
|
||||
this->connect(CLogHandler::instance(), &CLogHandler::localMessageLogged, this, &MainWindow::ps_displayStatusMessageInGui);
|
||||
this->connect(CLogHandler::instance(), &CLogHandler::remoteMessageLogged, this, &MainWindow::ps_displayStatusMessageInGui);
|
||||
auto *logHandler = CLogHandler::instance()->handlerForPattern(CLogPattern().withSeverityAtOrAbove(CStatusMessage::SeverityInfo));
|
||||
this->connect(logHandler, &CLogPatternHandler::messageLogged, this, &MainWindow::ps_displayStatusMessageInGui);
|
||||
|
||||
Q_ASSERT(connect);
|
||||
Q_UNUSED(connect); // suppress GCC warning in release build
|
||||
|
||||
Reference in New Issue
Block a user