mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-12 23:35:33 +08:00
Improved log level when DB reading fails
(Mapping between severity and read status flags)
This commit is contained in:
committed by
Mathew Sutcliffe
parent
3970b96eaf
commit
bcf1bed1d0
@@ -466,7 +466,14 @@ namespace BlackCore
|
|||||||
|
|
||||||
void CWebDataServices::ps_readFromSwiftDb(CEntityFlags::Entity entity, CEntityFlags::ReadState state, int number)
|
void CWebDataServices::ps_readFromSwiftDb(CEntityFlags::Entity entity, CEntityFlags::ReadState state, int number)
|
||||||
{
|
{
|
||||||
CLogMessage(this).info("Read data %1 entries: %2 state: %3") << CEntityFlags::flagToString(entity) << number << CEntityFlags::flagToString(state);
|
if (CEntityFlags::isWarningOrAbove(state))
|
||||||
|
{
|
||||||
|
CLogMessage(this).warning("Read data %1 entries: %2 state: %3") << CEntityFlags::flagToString(entity) << number << CEntityFlags::flagToString(state);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CLogMessage(this).info("Read data %1 entries: %2 state: %3") << CEntityFlags::flagToString(entity) << number << CEntityFlags::flagToString(state);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWebDataServices::readAllInBackground(int delayMs)
|
void CWebDataServices::readAllInBackground(int delayMs)
|
||||||
|
|||||||
@@ -66,24 +66,38 @@ namespace BlackMisc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CStatusMessage::StatusSeverity CEntityFlags::flagToSeverity(CEntityFlags::ReadState state)
|
||||||
|
{
|
||||||
|
switch (state)
|
||||||
|
{
|
||||||
|
case ReadFinished:
|
||||||
|
case StartRead:
|
||||||
|
default:
|
||||||
|
return CStatusMessage::SeverityInfo;
|
||||||
|
case ReadFailed:
|
||||||
|
return CStatusMessage::SeverityWarning;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CEntityFlags::isWarningOrAbove(CEntityFlags::ReadState state)
|
||||||
|
{
|
||||||
|
CStatusMessage::StatusSeverity s = flagToSeverity(state);
|
||||||
|
switch (s) {
|
||||||
|
case CStatusMessage::SeverityError:
|
||||||
|
case CStatusMessage::SeverityWarning:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CEntityFlags::registerMetadata()
|
void CEntityFlags::registerMetadata()
|
||||||
{
|
{
|
||||||
// this is no value class and I register enums here,
|
// this is no value class and I register enums here,
|
||||||
// that's why I do not use the Mixins
|
// that's why I do not use the Mixins
|
||||||
int id = qRegisterMetaType<CEntityFlags::Entity>();
|
qRegisterMetaType<CEntityFlags::Entity>();
|
||||||
// int idb = qDBusRegisterMetaType<CEntityFlags::Entity>();
|
qRegisterMetaType<CEntityFlags::EntityFlag>();
|
||||||
// Q_ASSERT_X(id >= 1024 && id == idb, Q_FUNC_INFO, "wrong id for metatype");
|
qRegisterMetaType<CEntityFlags::ReadState>();
|
||||||
Q_ASSERT_X(id >= 1024, Q_FUNC_INFO, "wrong id for metatype");
|
|
||||||
|
|
||||||
id = qRegisterMetaType<CEntityFlags::EntityFlag>();
|
|
||||||
// idb = qDBusRegisterMetaType<CEntityFlags::EntityFlag>();
|
|
||||||
Q_ASSERT_X(id >= 1024, Q_FUNC_INFO, "wrong id for metatype");
|
|
||||||
|
|
||||||
id = qRegisterMetaType<CEntityFlags::ReadState>();
|
|
||||||
// idb = qDBusRegisterMetaType<CEntityFlags::ReadState>();
|
|
||||||
Q_ASSERT_X(id >= 1024, Q_FUNC_INFO, "wrong id for metatype");
|
|
||||||
Q_UNUSED(id);
|
|
||||||
// Q_UNUSED(idb);
|
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#define BLACKMISC_NETWORK_ENTITRFLAGS_H
|
#define BLACKMISC_NETWORK_ENTITRFLAGS_H
|
||||||
|
|
||||||
#include "blackmisc/blackmiscexport.h"
|
#include "blackmisc/blackmiscexport.h"
|
||||||
|
#include "blackmisc/statusmessage.h"
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
namespace BlackMisc
|
namespace BlackMisc
|
||||||
@@ -62,6 +63,12 @@ namespace BlackMisc
|
|||||||
//! Convert to string
|
//! Convert to string
|
||||||
static QString flagToString(ReadState flag);
|
static QString flagToString(ReadState flag);
|
||||||
|
|
||||||
|
//! Flag to severity
|
||||||
|
static BlackMisc::CStatusMessage::StatusSeverity flagToSeverity(ReadState state);
|
||||||
|
|
||||||
|
//! Read state representing warning or above?
|
||||||
|
static bool isWarningOrAbove(ReadState state);
|
||||||
|
|
||||||
//! Register metadata
|
//! Register metadata
|
||||||
static void registerMetadata();
|
static void registerMetadata();
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user