Skip to content

Commit

Permalink
Normalize logging verbosity
Browse files Browse the repository at this point in the history
Generally lowers logging verbosity as the messages are often
unimportant for regular usage.

Also, message payload should only be logged in debug level.
  • Loading branch information
DavidB137 committed Mar 16, 2024
1 parent 5a3e950 commit 745c0a7
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
18 changes: 9 additions & 9 deletions include/common/spsp_bridge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ namespace SPSP::Nodes
topic.c_str(), payload.c_str());

if (topic.empty()) {
SPSP_LOGE("Can't publish to empty topic");
SPSP_LOGW("Can't publish to empty topic");
return false;
}

Expand All @@ -216,7 +216,7 @@ namespace SPSP::Nodes
SPSP_LOGD("Subscribing locally to topic '%s'", topic.c_str());

if (topic.empty()) {
SPSP_LOGE("Can't subscribe to empty topic");
SPSP_LOGW("Can't subscribe to empty topic");
return false;
}

Expand Down Expand Up @@ -269,7 +269,7 @@ namespace SPSP::Nodes
SPSP_LOGD("Unsubscribing locally from topic '%s'", topic.c_str());

if (topic.empty()) {
SPSP_LOGE("Can't unsubscribe from empty topic");
SPSP_LOGW("Can't unsubscribe from empty topic");
return false;
}

Expand Down Expand Up @@ -353,7 +353,7 @@ namespace SPSP::Nodes
}

if (req.topic.empty()) {
SPSP_LOGE("Can't publish to empty topic");
SPSP_LOGW("Can't publish to empty topic");
return false;
}

Expand All @@ -378,7 +378,7 @@ namespace SPSP::Nodes
}

if (req.topic.empty()) {
SPSP_LOGE("Can't subscribe to empty topic");
SPSP_LOGW("Can't subscribe to empty topic");
return false;
}

Expand Down Expand Up @@ -433,7 +433,7 @@ namespace SPSP::Nodes
}

if (req.topic.empty()) {
SPSP_LOGE("Can't unsubscribe from empty topic");
SPSP_LOGW("Can't unsubscribe from empty topic");
return false;
}

Expand Down Expand Up @@ -498,8 +498,8 @@ namespace SPSP::Nodes
bool publishSubData(const LocalAddrT& addr, const std::string& topic,
const std::string& payload)
{
SPSP_LOGD("Sending SUB_DATA to %s: topic '%s', payload '%s'",
addr.str.c_str(), topic.c_str(), payload.c_str());
SPSP_LOGD("Sending SUB_DATA to %s: topic '%s'",
addr.str.c_str(), topic.c_str());

LocalMessageT msg = {};
msg.addr = addr;
Expand Down Expand Up @@ -600,7 +600,7 @@ namespace SPSP::Nodes
m_subDB.remove(topic);
SPSP_LOGD("SubDB: Removed unused topic '%s'", topic.c_str());
} else {
SPSP_LOGE("SubDB: Topic '%s' can't be unsubscribed. Will try again in next tick.",
SPSP_LOGW("SubDB: Topic '%s' can't be unsubscribed. Will try again in next tick.",
topic.c_str());
}
}
Expand Down
8 changes: 4 additions & 4 deletions include/common/spsp_client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ namespace SPSP::Nodes
topic.c_str(), payload.c_str());

if (topic.empty()) {
SPSP_LOGE("Can't publish to empty topic");
SPSP_LOGW("Can't publish to empty topic");
return false;
}

Expand Down Expand Up @@ -170,7 +170,7 @@ namespace SPSP::Nodes
SPSP_LOGD("Subscribing to topic '%s'", topic.c_str());

if (topic.empty()) {
SPSP_LOGE("Can't subscribe to empty topic");
SPSP_LOGW("Can't subscribe to empty topic");
return false;
}

Expand Down Expand Up @@ -205,7 +205,7 @@ namespace SPSP::Nodes
SPSP_LOGD("Unsubscribing from topic '%s'", topic.c_str());

if (topic.empty()) {
SPSP_LOGE("Can't unsubscribe from empty topic");
SPSP_LOGW("Can't unsubscribe from empty topic");
return false;
}

Expand All @@ -220,7 +220,7 @@ namespace SPSP::Nodes
const std::scoped_lock lock(m_mutex);
if (!m_subDB.remove(topic)) {
// Not subscribed to this topic
SPSP_LOGD("Can't unsubscribe from not-subscribed topic '%s'",
SPSP_LOGW("Can't unsubscribe from not-subscribed topic '%s'",
topic.c_str());
return false;
}
Expand Down
6 changes: 3 additions & 3 deletions include/common/spsp_local_message.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ namespace SPSP
std::string toString() const
{
return std::string{localMessageTypeToStr(type)} + " " +
(addr.str.length() > 0 ? addr.str : ".") + " " +
(topic.length() > 0 ? topic : "-") + " " +
(payload.length() > 0 ? payload : "-");
(addr.str.length() > 0 ? addr.str : "(no addr)") + " " +
(topic.length() > 0 ? topic : "(no topic)") + " " +
"(" + std::to_string(payload.length()) + " B payload)";
}

bool operator==(const LocalMessage& other) const
Expand Down
2 changes: 1 addition & 1 deletion src/espidf/spsp_mqtt_adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace SPSP::FarLayers::MQTT
break;

case MQTT_EVENT_DISCONNECTED:
SPSP_LOGD("Disconnected, MQTT will reconnect automatically...");
SPSP_LOGW("Disconnected, MQTT will reconnect automatically...");
break;

case MQTT_EVENT_DATA:
Expand Down
6 changes: 3 additions & 3 deletions src/espidf/spsp_wifi_station.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ namespace SPSP::WiFi

SPSP_ERROR_CHECK(esp_wifi_set_channel(ch, WIFI_SECOND_CHAN_NONE),
ConnectionError("Set WiFi channel failed"));
SPSP_LOGI("Set channel %d", ch);
SPSP_LOGD("Set channel %d", ch);
}

void Station::setChannelRestrictions(const ChannelRestrictions& rest)
Expand Down Expand Up @@ -193,7 +193,7 @@ namespace SPSP::WiFi

SPSP_ERROR_CHECK(nvsInitCode, ConnectionError("NVS init failed"));

SPSP_LOGI("NVS initialized");
SPSP_LOGD("NVS initialized");
}

void Station::initNetIf()
Expand All @@ -216,7 +216,7 @@ namespace SPSP::WiFi
hostname += macStr;
esp_netif_set_hostname(m_netIf, hostname.c_str());

SPSP_LOGI("Network interface initialized");
SPSP_LOGD("Network interface initialized");
}

void Station::registerEventHandlers()
Expand Down
2 changes: 1 addition & 1 deletion src/linux/spsp_mqtt_adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ namespace SPSP::FarLayers::MQTT
{
auto inst = static_cast<Adapter*>(ctx);

SPSP_LOGI("Connection lost. Attempting reconnection...");
SPSP_LOGW("Connection lost. Attempting reconnection...");
inst->connect();
}

Expand Down

0 comments on commit 745c0a7

Please sign in to comment.