From 1a23e0631c413e4bf7176d8a68f4e2aece19b53a Mon Sep 17 00:00:00 2001 From: Kunlong Ma Date: Wed, 13 Mar 2024 14:50:39 +0800 Subject: [PATCH] ENH: add log for message delay(debug) JIRA: NONE Signed-off-by: Kunlong Ma Change-Id: I79792a7802a9ca64d20d8c0127bad4fa5c0a9d41 --- src/slic3r/GUI/DeviceManager.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index 45b1d6603..d98f4f868 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -2780,8 +2780,10 @@ int MachineObject::parse_json(std::string payload) std::string message_type = is_lan_mode_printer() ? "Local Mqtt" : is_tunnel_mqtt ? "Tunnel Mqtt" : "Cloud Mqtt"; if (!message_delay.empty()) { - auto [first_type, first_time_stamp, first_delay] = message_delay.front(); - auto [last_type, last_time_stap, last_delay] = message_delay.back(); + const auto& [first_type, first_time_stamp, first_delay] = message_delay.front(); + const auto& [last_type, last_time_stap, last_delay] = message_delay.back(); + + BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << ", message delay, last time stamp: " << last_time_stap; if (last_time_stap - first_time_stamp >= MINUTE_30) { // record, excluding current data int total = message_delay.size(); @@ -2793,7 +2795,7 @@ int MachineObject::parse_json(std::string payload) int tunnel_mqtt_timeout = 0; int cloud_mqtt_timeout = 0; - for (auto [type, time_stamp, delay] : message_delay) { + for (const auto& [type, time_stamp, delay] : message_delay) { if (type == "Local Mqtt") { local_mqtt++; if (delay >= TIME_OUT) { @@ -2807,14 +2809,14 @@ int MachineObject::parse_json(std::string payload) } } else if (type == "Cloud Mqtt"){ - cloud_mqtt_timeout++; + cloud_mqtt++; if (delay >= TIME_OUT) { cloud_mqtt_timeout++; } } } - message_delay.clear(); - BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", message total: " << total; + + BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << ", message delay, message total: " << total; try { if (m_agent) { json j_message; @@ -2836,6 +2838,9 @@ int MachineObject::parse_json(std::string payload) } } catch (...) {} + + message_delay.clear(); + message_delay.shrink_to_fit(); } } message_delay.push_back(std::make_tuple(message_type, t_utc, delay));