mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-26 02:35:38 +08:00
[xswiftbus] Stop logging probe failures after a certain number
To avoid flooding the log with messages.
This commit is contained in:
@@ -27,16 +27,21 @@ namespace XSwiftBus
|
|||||||
auto result = XPLMProbeTerrainXYZ(m_ref, static_cast<float>(x), static_cast<float>(y), static_cast<float>(z), &probe);
|
auto result = XPLMProbeTerrainXYZ(m_ref, static_cast<float>(x), static_cast<float>(y), static_cast<float>(z), &probe);
|
||||||
if (result != xplm_ProbeHitTerrain)
|
if (result != xplm_ProbeHitTerrain)
|
||||||
{
|
{
|
||||||
std::string error;
|
if (m_logMessageCount < 100)
|
||||||
if (result == xplm_ProbeError) { error = "probe error"; }
|
{
|
||||||
else if (result == xplm_ProbeMissed) { error = "probe missed"; }
|
m_logMessageCount++;
|
||||||
else { error = "unknown probe result"; }
|
std::string error;
|
||||||
WARNING_LOG(callsign + " " + error + " at " + std::to_string(degreesLatitude) + ", " + std::to_string(degreesLongitude) + ", " + std::to_string(metersAltitude));
|
if (result == xplm_ProbeError) { error = "probe error"; }
|
||||||
|
else if (result == xplm_ProbeMissed) { error = "probe missed"; }
|
||||||
|
else { error = "unknown probe result"; }
|
||||||
|
WARNING_LOG(callsign + " " + error + " at " + std::to_string(degreesLatitude) + ", " + std::to_string(degreesLongitude) + ", " + std::to_string(metersAltitude));
|
||||||
|
}
|
||||||
|
|
||||||
return std::numeric_limits<double>::quiet_NaN();
|
return std::numeric_limits<double>::quiet_NaN();
|
||||||
}
|
}
|
||||||
if (probe.is_wet)
|
if (probe.is_wet && m_logMessageCount < 100)
|
||||||
{
|
{
|
||||||
|
m_logMessageCount++;
|
||||||
DEBUG_LOG(callsign + " probe hit water at " + std::to_string(degreesLatitude) + ", " + std::to_string(degreesLongitude) + ", " + std::to_string(metersAltitude));
|
DEBUG_LOG(callsign + " probe hit water at " + std::to_string(degreesLatitude) + ", " + std::to_string(degreesLongitude) + ", " + std::to_string(metersAltitude));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ namespace XSwiftBus
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
XPLMProbeRef m_ref = nullptr;
|
XPLMProbeRef m_ref = nullptr;
|
||||||
|
mutable int m_logMessageCount = 0;
|
||||||
};
|
};
|
||||||
} // ns
|
} // ns
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user