fix: better logging behaviour

This commit is contained in:
Tobias Reisinger 2020-07-26 21:00:05 +02:00
parent 3e6d0333b7
commit 398019afe8
36 changed files with 256 additions and 188 deletions

View file

@ -18,7 +18,7 @@ api_v1_controllers_STR_GET(struct mg_connection *nc, struct http_message *hm, en
uuid_t target_uid;
if(uuid_parse(args[0].value.v_str, target_uid))
{
LOG_DEBUG("failed to unparse uid\n");
LOGGER_DEBUG("failed to unparse uid\n");
static const char content[] = "given id was invalid";
endpoint_response_text(response, 400, content, STRLEN(content));
@ -29,7 +29,7 @@ api_v1_controllers_STR_GET(struct mg_connection *nc, struct http_message *hm, en
if(!controller)
{
LOG_DEBUG("could not find a controller for uid '%s'\n", args[0].value.v_str);
LOGGER_DEBUG("could not find a controller for uid '%s'\n", args[0].value.v_str);
static const char content[] = "no controller for id found";
endpoint_response_text(response, 404, content, STRLEN(content));
@ -52,7 +52,7 @@ api_v1_controllers_STR_PUT(struct mg_connection *nc, struct http_message *hm, en
uuid_t target_uid;
if(uuid_parse(args[0].value.v_str, target_uid))
{
LOG_DEBUG("failed to unparse uid\n");
LOGGER_DEBUG("failed to unparse uid\n");
static const char content[] = "given id was invalid";
endpoint_response_text(response, 400, content, STRLEN(content));
@ -63,7 +63,7 @@ api_v1_controllers_STR_PUT(struct mg_connection *nc, struct http_message *hm, en
if(!controller)
{
LOG_DEBUG("could not find a controller for uid '%s'\n", args[0].value.v_str);
LOGGER_DEBUG("could not find a controller for uid '%s'\n", args[0].value.v_str);
static const char content[] = "no controller for id found";
endpoint_response_text(response, 404, content, STRLEN(content));
@ -130,7 +130,7 @@ api_v1_controllers_STR_PUT(struct mg_connection *nc, struct http_message *hm, en
if(controller_save(controller))
{
LOG_ERROR("failed to save controller\n");
LOGGER_ERR("failed to save controller\n");
controller_free(controller);
cJSON_Delete(json);
@ -160,7 +160,7 @@ api_v1_controllers_STR_DELETE(struct mg_connection *nc, struct http_message *hm,
uuid_t target_uid;
if(uuid_parse(target_uid_str, target_uid))
{
LOG_DEBUG("failed to unparse uid\n");
LOGGER_DEBUG("failed to unparse uid\n");
static const char content[] = "given id was invalid";
endpoint_response_text(response, 400, content, STRLEN(content));
@ -171,7 +171,7 @@ api_v1_controllers_STR_DELETE(struct mg_connection *nc, struct http_message *hm,
if(!controller)
{
LOG_DEBUG("could not find a controller for uid '%s'\n", args[0].value.v_str);
LOGGER_DEBUG("could not find a controller for uid '%s'\n", args[0].value.v_str);
static const char content[] = "no controller for id found";
endpoint_response_text(response, 404, content, STRLEN(content));
@ -180,7 +180,7 @@ api_v1_controllers_STR_DELETE(struct mg_connection *nc, struct http_message *hm,
if(controller_remove(controller))
{
LOG_ERROR("failed to remove controller from database\n");
LOGGER_ERR("failed to remove controller from database\n");
static const char content[] = "failed to remove controller from database";
endpoint_response_text(response, 500, content, STRLEN(content));