fix: better logging behaviour
This commit is contained in:
parent
3e6d0333b7
commit
398019afe8
36 changed files with 256 additions and 188 deletions
src/endpoints
|
@ -19,7 +19,7 @@ api_v1_schedules_STR_GET(struct mg_connection *nc, struct http_message *hm, endp
|
|||
uuid_t target_uid;
|
||||
if(schedule_uid_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));
|
||||
|
@ -30,7 +30,7 @@ api_v1_schedules_STR_GET(struct mg_connection *nc, struct http_message *hm, endp
|
|||
|
||||
if(!schedule)
|
||||
{
|
||||
LOG_DEBUG("could not find a schedule for uid '%s'\n", args[0].value.v_str);
|
||||
LOGGER_DEBUG("could not find a schedule for uid '%s'\n", args[0].value.v_str);
|
||||
|
||||
static const char content[] = "no schedule for id found";
|
||||
endpoint_response_text(response, 404, content, STRLEN(content));
|
||||
|
@ -53,7 +53,7 @@ api_v1_schedules_STR_PUT(struct mg_connection *nc, struct http_message *hm, endp
|
|||
uuid_t target_uid;
|
||||
if(schedule_uid_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));
|
||||
|
@ -64,7 +64,7 @@ api_v1_schedules_STR_PUT(struct mg_connection *nc, struct http_message *hm, endp
|
|||
|
||||
if(!schedule)
|
||||
{
|
||||
LOG_DEBUG("could not find a schedule for uid '%s'\n", args[0].value.v_str);
|
||||
LOGGER_DEBUG("could not find a schedule for uid '%s'\n", args[0].value.v_str);
|
||||
|
||||
static const char content[] = "no schedule for id found";
|
||||
endpoint_response_text(response, 404, content, STRLEN(content));
|
||||
|
@ -105,12 +105,12 @@ api_v1_schedules_STR_PUT(struct mg_connection *nc, struct http_message *hm, endp
|
|||
|
||||
if(!cJSON_IsString(json_period_start) || (json_period_start->valuestring == NULL))
|
||||
{
|
||||
LOG_DEBUG("period is missing start\n");
|
||||
LOGGER_DEBUG("period is missing start\n");
|
||||
continue;
|
||||
}
|
||||
if(!cJSON_IsString(json_period_end) || (json_period_end->valuestring == NULL))
|
||||
{
|
||||
LOG_DEBUG("period is missing end\n");
|
||||
LOGGER_DEBUG("period is missing end\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -118,12 +118,12 @@ api_v1_schedules_STR_PUT(struct mg_connection *nc, struct http_message *hm, endp
|
|||
uint16_t end;
|
||||
if(period_helper_parse_hhmm(json_period_start->valuestring, &start))
|
||||
{
|
||||
LOG_DEBUG("couldn't parse start '%s'\n", json_period_start->valuestring);
|
||||
LOGGER_DEBUG("couldn't parse start '%s'\n", json_period_start->valuestring);
|
||||
continue;
|
||||
}
|
||||
if(period_helper_parse_hhmm(json_period_end->valuestring, &end))
|
||||
{
|
||||
LOG_DEBUG("couldn't parse end '%s'\n", json_period_end->valuestring);
|
||||
LOGGER_DEBUG("couldn't parse end '%s'\n", json_period_end->valuestring);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ api_v1_schedules_STR_PUT(struct mg_connection *nc, struct http_message *hm, endp
|
|||
|
||||
if(schedule_save(schedule))
|
||||
{
|
||||
LOG_ERROR("failed to save schedule\n");
|
||||
LOGGER_ERR("failed to save schedule\n");
|
||||
free(schedule);
|
||||
cJSON_Delete(json);
|
||||
|
||||
|
@ -162,7 +162,7 @@ api_v1_schedules_STR_PUT(struct mg_connection *nc, struct http_message *hm, endp
|
|||
{
|
||||
if(!cJSON_IsString(json_tag) || (json_tag->valuestring == NULL))
|
||||
{
|
||||
LOG_DEBUG("invalid tag in tags\n");
|
||||
LOGGER_DEBUG("invalid tag in tags\n");
|
||||
continue;
|
||||
}
|
||||
const char *tag = json_tag->valuestring;
|
||||
|
@ -195,7 +195,7 @@ api_v1_schedules_STR_DELETE(struct mg_connection *nc, struct http_message *hm, e
|
|||
uuid_t target_uid;
|
||||
if(schedule_uid_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));
|
||||
|
@ -206,7 +206,7 @@ api_v1_schedules_STR_DELETE(struct mg_connection *nc, struct http_message *hm, e
|
|||
|
||||
if(!schedule)
|
||||
{
|
||||
LOG_DEBUG("could not find a schedule for uid '%s'\n", args[0].value.v_str);
|
||||
LOGGER_DEBUG("could not find a schedule for uid '%s'\n", args[0].value.v_str);
|
||||
|
||||
static const char content[] = "no schedule for id found";
|
||||
endpoint_response_text(response, 404, content, STRLEN(content));
|
||||
|
@ -224,7 +224,7 @@ api_v1_schedules_STR_DELETE(struct mg_connection *nc, struct http_message *hm, e
|
|||
|
||||
if(schedule_remove(schedule))
|
||||
{
|
||||
LOG_ERROR("failed to remove schedule from database\n");
|
||||
LOGGER_ERR("failed to remove schedule from database\n");
|
||||
|
||||
static const char content[] = "failed to remove schedule from database";
|
||||
endpoint_response_text(response, 500, content, STRLEN(content));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue