mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
logging commands
This commit is contained in:
@@ -317,12 +317,13 @@ uint8_t Command::call(const uint8_t device_type, const char * cmd, const char *
|
||||
// check if we have a matching command
|
||||
if (!cf) {
|
||||
// we didn't find the command, report error
|
||||
LOG_DEBUG("Command failed: invalid command '%s'", cmd ? cmd : "");
|
||||
LOG_WARNING("Command failed: invalid command '%s'", cmd ? cmd : "");
|
||||
return message(CommandRet::NOT_FOUND, "invalid command", output);
|
||||
}
|
||||
|
||||
// check permissions and abort if not authorized
|
||||
if (cf->has_flags(CommandFlag::ADMIN_ONLY) && !is_admin) {
|
||||
LOG_WARNING("Command failed: authentication failed");
|
||||
output["message"] = "authentication failed";
|
||||
return CommandRet::NOT_ALLOWED; // command not allowed
|
||||
}
|
||||
@@ -341,9 +342,9 @@ uint8_t Command::call(const uint8_t device_type, const char * cmd, const char *
|
||||
LOG_DEBUG(("%sCalling command %s"), ro.c_str(), info_s);
|
||||
} else {
|
||||
if (id > 0) {
|
||||
LOG_DEBUG(("%sCalling command %s with value %s and id %d on device 0x%02X"), ro.c_str(), info_s, value, id, device_id);
|
||||
LOG_INFO(("%sCalling command %s with value %s and id %d on device 0x%02X"), ro.c_str(), info_s, value, id, device_id);
|
||||
} else {
|
||||
LOG_DEBUG(("%sCalling command %s with value %s"), ro.c_str(), info_s, value);
|
||||
LOG_INFO(("%sCalling command %s with value %s"), ro.c_str(), info_s, value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -362,6 +363,11 @@ uint8_t Command::call(const uint8_t device_type, const char * cmd, const char *
|
||||
|
||||
// report back. If not OK show output from error, other return the HTTP code
|
||||
if (return_code != CommandRet::OK) {
|
||||
if (value == nullptr) {
|
||||
LOG_ERROR("Command '%s' failed with code: %d", cmd, return_code);
|
||||
} else {
|
||||
LOG_ERROR("Command '%s:%s' failed with code: %d", cmd, value, return_code);
|
||||
}
|
||||
return message(return_code, "callback function failed", output);
|
||||
}
|
||||
return return_code;
|
||||
|
||||
Reference in New Issue
Block a user