prettier logger
This commit is contained in:
16
src/hass.cpp
16
src/hass.cpp
@@ -19,7 +19,7 @@ void HomeAssistant::event_handler(struct lws* wsi, enum lws_callback_reasons rea
|
||||
ArduinoJson::JsonDocument json;
|
||||
switch (reason) {
|
||||
case LWS_CALLBACK_CLIENT_CONNECTION_ERROR: {
|
||||
log(LOG::ERR, "HomeAssistant::event_handler", "websocket conn error: {}", in ? in : "(null)");
|
||||
log(LOG::ERR, "websocket conn error: {}", in ? in : "(null)");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ void HomeAssistant::event_handler(struct lws* wsi, enum lws_callback_reasons rea
|
||||
}
|
||||
|
||||
if (ha_type == "auth_ok") {
|
||||
log(LOG::INF, "HomeAssistant::event_handler", "subscribing to entity \"{}\"", entity);
|
||||
log(LOG::INF, "subscribing to entity \"{}\"", entity);
|
||||
json.clear();
|
||||
json["id"] = id++;
|
||||
json["type"] = "subscribe_entities";
|
||||
@@ -47,7 +47,7 @@ void HomeAssistant::event_handler(struct lws* wsi, enum lws_callback_reasons rea
|
||||
|
||||
if (ha_type == "result") {
|
||||
if (json["success"].as<std::string>() == "false")
|
||||
log(LOG::ERR, "HomeAssistant::event_handler", "api said success was \"false\" on message id {}", id - 1);
|
||||
log(LOG::ERR, "api said success was \"false\" on message id {}", id - 1);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -56,17 +56,17 @@ void HomeAssistant::event_handler(struct lws* wsi, enum lws_callback_reasons rea
|
||||
break;
|
||||
}
|
||||
|
||||
log(LOG::WRN, "HomeAssistant::event_handler", "unhandled event: {}", (char*)in);
|
||||
log(LOG::WRN, "unhandled event: {}", (char*)in);
|
||||
break;
|
||||
}
|
||||
|
||||
case LWS_CALLBACK_CLIENT_ESTABLISHED: {
|
||||
log(LOG::INF, "HomeAssistant::event_handler", "Websocket connected");
|
||||
log(LOG::INF, "Websocket connected");
|
||||
break;
|
||||
}
|
||||
|
||||
case LWS_CALLBACK_CLIENT_CLOSED: {
|
||||
log(LOG::INF, "HomeAssistant::event_handler", "Websocket closed");
|
||||
log(LOG::INF, "Websocket closed");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ int HomeAssistant::connect() {
|
||||
|
||||
context = lws_create_context(&info);
|
||||
if (!context) {
|
||||
log(LOG::ERR, "HomeAssistant::connect", "error creating context");
|
||||
log(LOG::ERR, "error creating context");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ int HomeAssistant::connect() {
|
||||
|
||||
websock = lws_client_connect_via_info(&i);
|
||||
if (!websock) {
|
||||
log(LOG::ERR, "HomeAssistant::connect", "error creating lws client");
|
||||
log(LOG::ERR, "error creating lws client");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user