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));

View file

@ -15,7 +15,7 @@ api_v1_controllers_STR_relays_GET(struct mg_connection *nc, struct http_message
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));
@ -26,7 +26,7 @@ api_v1_controllers_STR_relays_GET(struct mg_connection *nc, struct http_message
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));

View file

@ -18,7 +18,7 @@ api_v1_controllers_STR_relays_INT_GET(struct mg_connection *nc, struct http_mess
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_relays_INT_GET(struct mg_connection *nc, struct http_mess
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));
@ -40,7 +40,7 @@ api_v1_controllers_STR_relays_INT_GET(struct mg_connection *nc, struct http_mess
if(!relay)
{
LOG_DEBUG("could not find a relay with num %d for controller '%s'\n", args[1].value.v_int, args[0].value.v_str);
LOGGER_DEBUG("could not find a relay with num %d for controller '%s'\n", args[1].value.v_int, args[0].value.v_str);
static const char content[] = "no relay for this controller found";
endpoint_response_text(response, 404, content, STRLEN(content));
@ -64,7 +64,7 @@ api_v1_controllers_STR_relays_INT_PUT(struct mg_connection *nc, struct http_mess
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));
@ -75,7 +75,7 @@ api_v1_controllers_STR_relays_INT_PUT(struct mg_connection *nc, struct http_mess
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));
@ -134,7 +134,7 @@ api_v1_controllers_STR_relays_INT_PUT(struct mg_connection *nc, struct http_mess
cJSON *json_schedule_uid = cJSON_GetObjectItemCaseSensitive(json_schedule, "id");
if(!cJSON_IsString(json_schedule_uid) || (json_schedule_uid->valuestring == NULL))
{
LOG_DEBUG("schedules[%d] is missing uid\n", schedule_position);
LOGGER_DEBUG("schedules[%d] is missing uid\n", schedule_position);
cJSON_Delete(json);
static const char content[] = "at least one schedule is missing an id";
@ -144,7 +144,7 @@ api_v1_controllers_STR_relays_INT_PUT(struct mg_connection *nc, struct http_mess
uuid_t target_uid;
if(schedule_uid_parse(json_schedule_uid->valuestring, target_uid))
{
LOG_DEBUG("schedules[%d] has bad uid\n", schedule_position);
LOGGER_DEBUG("schedules[%d] has bad uid\n", schedule_position);
cJSON_Delete(json);
static const char content[] = "at least one schedule has a bad id";
@ -174,7 +174,7 @@ api_v1_controllers_STR_relays_INT_PUT(struct mg_connection *nc, struct http_mess
uuid_t target_uid;
if(schedule_uid_parse(json_active_schedule_uid->valuestring, target_uid))
{
LOG_DEBUG("active_schedule has bad uid\n");
LOGGER_DEBUG("active_schedule has bad uid\n");
cJSON_Delete(json);
static const char content[] = "active_schedule has a bad id";
@ -187,7 +187,7 @@ api_v1_controllers_STR_relays_INT_PUT(struct mg_connection *nc, struct http_mess
if(relay_save(relay))
{
LOG_ERROR("failed to save relay\n");
LOGGER_ERR("failed to save relay\n");
free(controller);
cJSON_Delete(json);
@ -206,7 +206,7 @@ api_v1_controllers_STR_relays_INT_PUT(struct mg_connection *nc, struct http_mess
{
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;

View file

@ -18,7 +18,7 @@ api_v1_controllers_STR_relays_INT_pulse_POST(struct mg_connection *nc, struct ht
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_relays_INT_pulse_POST(struct mg_connection *nc, struct ht
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));
@ -40,7 +40,7 @@ api_v1_controllers_STR_relays_INT_pulse_POST(struct mg_connection *nc, struct ht
if(!relay)
{
LOG_DEBUG("could not find a relay with num %d for controller '%s'\n", args[1].value.v_int, args[0].value.v_str);
LOGGER_DEBUG("could not find a relay with num %d for controller '%s'\n", args[1].value.v_int, args[0].value.v_str);
static const char content[] = "no relay for this controller found";
endpoint_response_text(response, 404, content, STRLEN(content));

View file

@ -30,21 +30,21 @@ bind_tcp_server(const char *addr, const char *port, int max_client_backlog)
if ((status = getaddrinfo(addr, port, &hints, &res)) != 0)
{
LOG_ERROR("error getting address info: %s\n", gai_strerror(status));
LOGGER_ERR("error getting address info: %s\n", gai_strerror(status));
}
fd = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
if ((status = bind(fd, res->ai_addr, res->ai_addrlen)) == -1)
{
LOG_ERROR("error binding socket: %s\n", status);
LOGGER_ERR("error binding socket: %s\n", status);
freeaddrinfo(res);
return -1;
}
if ((status = listen(fd, max_client_backlog)) == -1)
{
LOG_ERROR("error setting up listener: %s\n", status);
LOGGER_ERR("error setting up listener: %s\n", status);
freeaddrinfo(res);
return -1;
}
@ -78,14 +78,14 @@ send_udp_broadcast(const char *addr, uint16_t port, void *message, size_t length
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
{
LOG_ERROR("error creating socket\n");
LOGGER_ERR("error creating socket\n");
return -1;
}
int broadcast = 1;
if (setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &broadcast, sizeof broadcast) < 0)
{
LOG_ERROR("error setting broadcast\n");
LOGGER_ERR("error setting broadcast\n");
return -1;
}
@ -96,7 +96,7 @@ send_udp_broadcast(const char *addr, uint16_t port, void *message, size_t length
if(sendto(fd, message, length, 0, (struct sockaddr *)&their_addr, sizeof(their_addr)) < 0)
{
LOG_ERROR("error sending broadcast (%d): '%s'\n", errno, strerror(errno));
LOGGER_ERR("error sending broadcast (%d): '%s'\n", errno, strerror(errno));
return -1;
}
close(fd);
@ -114,7 +114,7 @@ api_v1_controllers_discover_POST(struct mg_connection *nc, struct http_message *
if(discover_server_port == -1)
{
LOG_ERROR("failed to get server port for discovery\n");
LOGGER_ERR("failed to get server port for discovery\n");
static const char content[] = "";
response->status_code = 500;
response->content_type = "text/plain";
@ -129,7 +129,7 @@ api_v1_controllers_discover_POST(struct mg_connection *nc, struct http_message *
if(send_udp_broadcast("255.255.255.255", global_config.discovery_port, payload, sizeof(payload)) < 0)
{
LOG_ERROR("failed to send UDP broadcast\n");
LOGGER_ERR("failed to send UDP broadcast\n");
static const char content[] = "";
response->status_code = 500;
response->content_type = "text/plain";
@ -168,7 +168,7 @@ api_v1_controllers_discover_POST(struct mg_connection *nc, struct http_message *
{
if((client_fd = accept(discover_server_socket, (struct sockaddr *) &their_addr, &addr_size)) < 0)
{
LOG_ERROR("error accepting client %s\n", strerror(errno));
LOGGER_ERR("error accepting client %s\n", strerror(errno));
continue;
}
@ -176,7 +176,7 @@ api_v1_controllers_discover_POST(struct mg_connection *nc, struct http_message *
if(recv(client_fd, &payload_length, sizeof(payload_length), 0) <= 0)
{
LOG_ERROR("error receiving header from client\n");
LOGGER_ERR("error receiving header from client\n");
continue;
}
@ -185,7 +185,7 @@ api_v1_controllers_discover_POST(struct mg_connection *nc, struct http_message *
if((bytes_transferred = recv(client_fd, answer_payload, payload_length, 0)) <= 0)
{
LOG_ERROR("error receiving payload from client\n");
LOGGER_ERR("error receiving payload from client\n");
continue;
}
@ -194,7 +194,7 @@ api_v1_controllers_discover_POST(struct mg_connection *nc, struct http_message *
if(getpeername(client_fd, (struct sockaddr *)&addr, &client_addr_size) != 0)
{
LOG_ERROR("error receiving payload from client\n");
LOGGER_ERR("error receiving payload from client\n");
continue;
}
@ -301,7 +301,7 @@ api_v1_controllers_discover_POST(struct mg_connection *nc, struct http_message *
{
known_controllers[i]->active = false;
controller_save(known_controllers[i]);
LOG_DEBUG("lost: %s\n", known_controllers[i]->name);
LOGGER_DEBUG("lost: %s\n", known_controllers[i]->name);
}
controller_free_list(known_controllers);

View file

@ -23,7 +23,7 @@ api_v1_relays_tag_STR_GET(struct mg_connection *nc, struct http_message *hm, end
int *relays_ids = junction_tag_get_relays_for_tag_id(tag_id);
if(relays_ids == NULL)
{
LOG_ERROR("failed to load relays for tag from database\n");
LOGGER_ERR("failed to load relays for tag from database\n");
static const char content[] = "failed to load relays for tag from database";
endpoint_response_text(response, 500, content, STRLEN(content));

View file

@ -24,7 +24,7 @@ api_v1_schedules_POST(struct mg_connection *nc, struct http_message *hm, endpoin
cJSON *json_name = cJSON_GetObjectItemCaseSensitive(json, "name");
if(!cJSON_IsString(json_name) || (json_name->valuestring == NULL))
{
LOG_DEBUG("no name for schedule provided\n");
LOGGER_DEBUG("no name for schedule provided\n");
cJSON_Delete(json);
static const char content[] = "no name for schedule provided";
@ -34,7 +34,7 @@ api_v1_schedules_POST(struct mg_connection *nc, struct http_message *hm, endpoin
cJSON *json_periods = cJSON_GetObjectItemCaseSensitive(json, "periods");
if(!cJSON_IsArray(json_periods))
{
LOG_DEBUG("no periods for schedule provided\n");
LOGGER_DEBUG("no periods for schedule provided\n");
cJSON_Delete(json);
static const char content[] = "no periods for schedule provided";
@ -48,7 +48,7 @@ api_v1_schedules_POST(struct mg_connection *nc, struct http_message *hm, endpoin
{
if(!cJSON_IsString(json_tag) || (json_tag->valuestring == NULL))
{
LOG_DEBUG("invalid tag in tags\n");
LOGGER_DEBUG("invalid tag in tags\n");
cJSON_Delete(json);
static const char content[] = "invalid tag in tags";
@ -78,7 +78,7 @@ api_v1_schedules_POST(struct mg_connection *nc, struct http_message *hm, endpoin
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");
cJSON_Delete(json);
schedule_free(new_schedule);
@ -88,7 +88,7 @@ api_v1_schedules_POST(struct mg_connection *nc, struct http_message *hm, endpoin
}
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");
cJSON_Delete(json);
schedule_free(new_schedule);
@ -101,7 +101,7 @@ api_v1_schedules_POST(struct mg_connection *nc, struct http_message *hm, endpoin
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);
cJSON_Delete(json);
schedule_free(new_schedule);
@ -111,7 +111,7 @@ api_v1_schedules_POST(struct mg_connection *nc, struct http_message *hm, endpoin
}
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);
cJSON_Delete(json);
schedule_free(new_schedule);

View file

@ -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));

View file

@ -28,7 +28,7 @@ api_v1_schedules_list_POST(struct mg_connection *nc, struct http_message *hm, en
cJSON *json_name = cJSON_GetObjectItemCaseSensitive(json, "name");
if(!cJSON_IsString(json_name) || (json_name->valuestring == NULL))
{
LOG_DEBUG("no name for schedule provided\n");
LOGGER_DEBUG("no name for schedule provided\n");
cJSON_Delete(json_list);
static const char content[] = "no name for schedule provided";
@ -38,7 +38,7 @@ api_v1_schedules_list_POST(struct mg_connection *nc, struct http_message *hm, en
cJSON *json_periods = cJSON_GetObjectItemCaseSensitive(json, "periods");
if(!cJSON_IsArray(json_periods))
{
LOG_DEBUG("no periods for schedule provided\n");
LOGGER_DEBUG("no periods for schedule provided\n");
cJSON_Delete(json_list);
static const char content[] = "no periods for schedule provided";
@ -52,7 +52,7 @@ api_v1_schedules_list_POST(struct mg_connection *nc, struct http_message *hm, en
{
if(!cJSON_IsString(json_tag) || (json_tag->valuestring == NULL))
{
LOG_DEBUG("invalid tag in tags\n");
LOGGER_DEBUG("invalid tag in tags\n");
cJSON_Delete(json_list);
static const char content[] = "invalid tag in tags";
@ -82,7 +82,7 @@ api_v1_schedules_list_POST(struct mg_connection *nc, struct http_message *hm, en
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");
cJSON_Delete(json_list);
schedule_free(new_schedule);
@ -92,7 +92,7 @@ api_v1_schedules_list_POST(struct mg_connection *nc, struct http_message *hm, en
}
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");
cJSON_Delete(json_list);
schedule_free(new_schedule);
@ -105,7 +105,7 @@ api_v1_schedules_list_POST(struct mg_connection *nc, struct http_message *hm, en
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);
cJSON_Delete(json_list);
schedule_free(new_schedule);
@ -115,7 +115,7 @@ api_v1_schedules_list_POST(struct mg_connection *nc, struct http_message *hm, en
}
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);
cJSON_Delete(json_list);
schedule_free(new_schedule);

View file

@ -23,7 +23,7 @@ api_v1_schedules_tag_STR_GET(struct mg_connection *nc, struct http_message *hm,
int *schedules_ids = junction_tag_get_schedules_for_tag_id(tag_id);
if(schedules_ids == NULL)
{
LOG_ERROR("failed to load schedules for tag from database\n");
LOGGER_ERR("failed to load schedules for tag from database\n");
static const char content[] = "failed to load schedules for tag from database";
endpoint_response_text(response, 500, content, STRLEN(content));

View file

@ -21,7 +21,7 @@ api_v1_tags_GET(struct mg_connection *nc, struct http_message *hm, endpoint_args
cJSON *json_tag = cJSON_CreateString(all_tags[i]);
if (json_tag == NULL)
{
LOG_DEBUG("failed to add tag from string '%s'\n", all_tags[i]);
LOGGER_DEBUG("failed to add tag from string '%s'\n", all_tags[i]);
free(all_tags[i]);
continue;
}

View file

@ -23,7 +23,7 @@ api_v1_tags_STR_GET(struct mg_connection *nc, struct http_message *hm, endpoint_
int *relays_ids = junction_tag_get_relays_for_tag_id(tag_id);
if(relays_ids == NULL)
{
LOG_ERROR("failed to load relays for tag from database\n");
LOGGER_ERR("failed to load relays for tag from database\n");
static const char content[] = "failed to load relays for tag from database";
endpoint_response_text(response, 500, content, STRLEN(content));
@ -32,7 +32,7 @@ api_v1_tags_STR_GET(struct mg_connection *nc, struct http_message *hm, endpoint_
int *schedules_ids = junction_tag_get_schedules_for_tag_id(tag_id);
if(schedules_ids == NULL)
{
LOG_ERROR("failed to load schedules for tag from database\n");
LOGGER_ERR("failed to load schedules for tag from database\n");
static const char content[] = "failed to load schedules for tag from database";
endpoint_response_text(response, 500, content, STRLEN(content));
@ -98,7 +98,7 @@ api_v1_tags_STR_DELETE(struct mg_connection *nc, struct http_message *hm, endpoi
if(tag_remove(tag_id))
{
LOG_ERROR("failed to remove tag from database\n");
LOGGER_ERR("failed to remove tag from database\n");
static const char content[] = "failed to remove tag from database";
endpoint_response_text(response, 500, content, STRLEN(content));