mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 04:25:35 +08:00
Human readable log category:
* fixed propertyIndex in CStatusMessage * added method for human readable messages in CStatusMessage * added typeid based category for classes * listmodel for staus messages, added column and removed outdated data method * columns, in class init
This commit is contained in:
committed by
Roland Winklmeier
parent
6e5e28584f
commit
97e04f8360
@@ -1,7 +1,7 @@
|
||||
/* Copyright (C) 2014
|
||||
* Swift Project Community / Contributors
|
||||
* swift Project Community / Contributors
|
||||
*
|
||||
* This file is part of Swift Project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* This file is part of swift Project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of Swift Project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
@@ -117,4 +117,4 @@ namespace BlackMisc
|
||||
Q_DECLARE_METATYPE(BlackMisc::CLogCategory)
|
||||
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::CLogCategory, (o.m_string))
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <QObject>
|
||||
#include <QThreadStorage>
|
||||
#include <type_traits>
|
||||
#include <typeinfo>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
@@ -141,4 +142,4 @@ Q_DECLARE_METATYPE(BlackMisc::CLogCategoryList)
|
||||
Q_DECLARE_METATYPE(BlackMisc::CCollection<BlackMisc::CLogCategory>)
|
||||
Q_DECLARE_METATYPE(BlackMisc::CSequence<BlackMisc::CLogCategory>)
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -45,10 +45,7 @@ namespace BlackMisc
|
||||
{
|
||||
default:
|
||||
case QtDebugMsg:
|
||||
if (debug)
|
||||
this->m_severity = SeverityDebug;
|
||||
else
|
||||
this->m_severity = SeverityInfo;
|
||||
this->m_severity = debug ? SeverityDebug : SeverityInfo;
|
||||
break;
|
||||
case QtWarningMsg:
|
||||
this->m_severity = SeverityWarning;
|
||||
@@ -94,6 +91,31 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
|
||||
QString CStatusMessage::getHumanReadableCategory() const
|
||||
{
|
||||
if (this->m_humanReadableCategory.isEmpty())
|
||||
{
|
||||
const QString cat(this->m_categories.toQString());
|
||||
// could als be subject of i18n
|
||||
// from sepcific to unspecific
|
||||
if (cat.isEmpty()) { this->m_humanReadableCategory = "None"; }
|
||||
else if (cat.contains(CLogCategory::validation().toQString())) { this->m_humanReadableCategory = "Validation"; }
|
||||
else if (cat.contains("ContextAudio")) { this->m_humanReadableCategory = "Audio"; }
|
||||
else if (cat.contains("ContextSimulator")) { this->m_humanReadableCategory = "Simulator"; }
|
||||
else if (cat.contains("ContextNetwork")) { this->m_humanReadableCategory = "Network"; }
|
||||
else if (cat.contains("Vatlib")) { this->m_humanReadableCategory = "VATSIM library"; }
|
||||
else if (cat.contains("BlackMisc")) { this->m_humanReadableCategory = "Library"; }
|
||||
else if (cat.contains("BlackCore")) { this->m_humanReadableCategory = "Core"; }
|
||||
else if (cat.contains("BlackGui")) { this->m_humanReadableCategory = "GUI"; }
|
||||
else if (cat.contains("BlackSound")) { this->m_humanReadableCategory = "GUI"; }
|
||||
else if (cat.contains("XPlane")) { this->m_humanReadableCategory = "XPlane"; }
|
||||
else if (cat.contains("FSX")) { this->m_humanReadableCategory = "FSX"; }
|
||||
else if (cat.contains("FS9")) { this->m_humanReadableCategory = "FS9"; }
|
||||
else this->m_humanReadableCategory = "Misc.";
|
||||
}
|
||||
return this->m_humanReadableCategory;
|
||||
}
|
||||
|
||||
/*
|
||||
* Handled by
|
||||
*/
|
||||
@@ -238,15 +260,13 @@ namespace BlackMisc
|
||||
if (this->m_timestamp.isNull() || !this->m_timestamp.isValid()) return "";
|
||||
return this->m_timestamp.toString("HH:mm::ss.zzz");
|
||||
}
|
||||
case IndexCategory:
|
||||
case IndexCategories:
|
||||
return QVariant(this->m_categories.toQString());
|
||||
case IndexCategoryHumanReadable:
|
||||
return QVariant(this->getHumanReadableCategory());
|
||||
default:
|
||||
break;
|
||||
return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
|
||||
Q_ASSERT_X(false, "CStatusMessage", "index unknown");
|
||||
QString m = QString("no property, index ").append(index.toQString());
|
||||
return QVariant::fromValue(m);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -271,7 +291,7 @@ namespace BlackMisc
|
||||
case IndexSeverity:
|
||||
this->m_severity = static_cast<StatusSeverity>(variant.value<uint>());
|
||||
break;
|
||||
case IndexCategory:
|
||||
case IndexCategories:
|
||||
this->m_categories = variant.value<CLogCategoryList>();
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -38,7 +38,8 @@ namespace BlackMisc
|
||||
//! Properties by index
|
||||
enum ColumnIndex
|
||||
{
|
||||
IndexCategory = BlackMisc::CPropertyIndex::GlobalIndexCStatusMessage,
|
||||
IndexCategories = BlackMisc::CPropertyIndex::GlobalIndexCStatusMessage,
|
||||
IndexCategoryHumanReadable,
|
||||
IndexSeverity,
|
||||
IndexSeverityAsString,
|
||||
IndexMessage,
|
||||
@@ -69,6 +70,9 @@ namespace BlackMisc
|
||||
//! Message category
|
||||
const CLogCategoryList &getCategories() const { return this->m_categories; }
|
||||
|
||||
//! Human readable category
|
||||
QString getHumanReadableCategory() const;
|
||||
|
||||
//! Message severity
|
||||
StatusSeverity getSeverity() const { return this->m_severity; }
|
||||
|
||||
@@ -127,11 +131,13 @@ namespace BlackMisc
|
||||
private:
|
||||
BLACK_ENABLE_TUPLE_CONVERSION(CStatusMessage)
|
||||
CLogCategoryList m_categories;
|
||||
StatusSeverity m_severity = SeverityDebug;
|
||||
QString m_message;
|
||||
QDateTime m_timestamp = QDateTime::currentDateTimeUtc();
|
||||
bool m_redundant = false;
|
||||
StatusSeverity m_severity = SeverityDebug;
|
||||
QString m_message;
|
||||
QDateTime m_timestamp = QDateTime::currentDateTimeUtc();
|
||||
bool m_redundant = false;
|
||||
mutable QVector<quintptr> m_handledByObjects;
|
||||
mutable QString m_humanReadableCategory; //!< human readable category cache
|
||||
|
||||
};
|
||||
} // namespace
|
||||
|
||||
|
||||
Reference in New Issue
Block a user