fix: better logging behaviour
This commit is contained in:
parent
3e6d0333b7
commit
398019afe8
36 changed files with 255 additions and 187 deletions
|
|
@ -1,6 +1,6 @@
|
|||
cmake_minimum_required (VERSION 3.7)
|
||||
project(core
|
||||
VERSION 0.2.3
|
||||
VERSION 0.2.4
|
||||
LANGUAGES C)
|
||||
|
||||
add_executable(core src/main.c)
|
||||
|
|
|
|||
1
core.ini
1
core.ini
|
|
@ -13,3 +13,4 @@ discovery-port = 4421
|
|||
mqtt-port = 1885
|
||||
|
||||
log-level = debug
|
||||
log-file = stdout
|
||||
|
|
|
|||
|
|
@ -12,23 +12,14 @@ typedef enum
|
|||
RUN_TYPE_INVALID,
|
||||
} run_type_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LOG_LEVEL_TRACE = 5,
|
||||
LOG_LEVEL_DEBUG = 4,
|
||||
LOG_LEVEL_INFO = 3,
|
||||
LOG_LEVEL_WARN = 2,
|
||||
LOG_LEVEL_ERROR = 1,
|
||||
LOG_LEVEL_FATAL = 0,
|
||||
} log_level_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char *file;
|
||||
char database[256];
|
||||
char user[256];
|
||||
char group[256];
|
||||
log_level_t log_level;
|
||||
int log_level;
|
||||
FILE *log_file;
|
||||
run_type_t run_type;
|
||||
uint16_t server_port;
|
||||
uint16_t discovery_port;
|
||||
|
|
|
|||
|
|
@ -3,18 +3,20 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <syslog.h>
|
||||
|
||||
#include <colors.h>
|
||||
#include <config.h>
|
||||
|
||||
void
|
||||
logger_log(FILE *stream, log_level_t level, const char *filename, int line, const char *func, const char *msg, ...);
|
||||
logger_log(int level, const char *filename, int line, const char *func, const char *msg, ...);
|
||||
|
||||
#define LOG_TRACE(...) logger_log(stdout, LOG_LEVEL_TRACE, __FILE__, __LINE__, __func__, ##__VA_ARGS__)
|
||||
#define LOG_DEBUG(...) logger_log(stdout, LOG_LEVEL_DEBUG, __FILE__, __LINE__, __func__, ##__VA_ARGS__)
|
||||
#define LOG_INFO(...) logger_log(stdout, LOG_LEVEL_INFO , __FILE__, __LINE__, __func__, ##__VA_ARGS__)
|
||||
#define LOG_WARN(...) logger_log(stdout, LOG_LEVEL_WARN , __FILE__, __LINE__, __func__, ##__VA_ARGS__)
|
||||
#define LOG_ERROR(...) logger_log(stderr, LOG_LEVEL_ERROR, __FILE__, __LINE__, __func__, ##__VA_ARGS__)
|
||||
#define LOG_FATAL(...) logger_log(stderr, LOG_LEVEL_FATAL, __FILE__, __LINE__, __func__, ##__VA_ARGS__)
|
||||
#define LOGGER_DEBUG(...) logger_log(LOG_DEBUG , __FILE__, __LINE__, __func__, ##__VA_ARGS__)
|
||||
#define LOGGER_INFO(...) logger_log(LOG_INFO , __FILE__, __LINE__, __func__, ##__VA_ARGS__)
|
||||
#define LOGGER_NOTICE(...) logger_log(LOG_NOTICE , __FILE__, __LINE__, __func__, ##__VA_ARGS__)
|
||||
#define LOGGER_WARNING(...) logger_log(LOG_WARNING, __FILE__, __LINE__, __func__, ##__VA_ARGS__)
|
||||
#define LOGGER_ERR(...) logger_log(LOG_ERR , __FILE__, __LINE__, __func__, ##__VA_ARGS__)
|
||||
#define LOGGER_CRIT(...) logger_log(LOG_CRIT , __FILE__, __LINE__, __func__, ##__VA_ARGS__)
|
||||
#define LOGGER_EMERG(...) logger_log(LOG_EMERG , __FILE__, __LINE__, __func__, ##__VA_ARGS__)
|
||||
|
||||
#endif //CORE_LOGGER_H
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ command_set_relay_schedule(relay_t *relay)
|
|||
controller_t *controller = controller_get_by_id(relay->controller_id);
|
||||
if(!controller)
|
||||
{
|
||||
LOG_ERROR("couldn't find controller\n");
|
||||
LOGGER_ERR("couldn't find controller\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -66,7 +66,7 @@ command_set_relay_schedule(relay_t *relay)
|
|||
// finish writing
|
||||
if (mpack_writer_destroy(&writer) != mpack_ok)
|
||||
{
|
||||
LOG_ERROR("an error occurred encoding the data");
|
||||
LOGGER_ERR("an error occurred encoding the data");
|
||||
controller_free(controller);
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -100,7 +100,7 @@ command_set_controller_name(controller_t *controller)
|
|||
// finish writing
|
||||
if (mpack_writer_destroy(&writer) != mpack_ok)
|
||||
{
|
||||
LOG_ERROR("an error occurred encoding the data");
|
||||
LOGGER_ERR("an error occurred encoding the data");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -113,7 +113,7 @@ command_set_controller_name(controller_t *controller)
|
|||
int
|
||||
command_send(controller_t *controller, int command_code, char *payload, uint32_t payload_size)
|
||||
{
|
||||
LOG_DEBUG("commanding %d\n", command_code);
|
||||
LOGGER_DEBUG("commanding %d\n", command_code);
|
||||
|
||||
int bytes_transferred;
|
||||
|
||||
|
|
@ -121,18 +121,18 @@ command_send(controller_t *controller, int command_code, char *payload, uint32_t
|
|||
|
||||
if(fd_controller == -1)
|
||||
{
|
||||
LOG_ERROR("can't open command socket %s:%d\n", controller->ip, controller->port);
|
||||
LOGGER_ERR("can't open command socket %s:%d\n", controller->ip, controller->port);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if((bytes_transferred = send(fd_controller, &payload_size, sizeof(payload_size), 0)) <= 0)
|
||||
{
|
||||
LOG_ERROR("error during sending size\n");
|
||||
LOGGER_ERR("error during sending size\n");
|
||||
return 1;
|
||||
}
|
||||
if((bytes_transferred = send(fd_controller, payload, payload_size, 0)) <= 0)
|
||||
{
|
||||
LOG_ERROR("error during sending\n");
|
||||
LOGGER_ERR("error during sending\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -146,7 +146,7 @@ command_pulse(relay_t *relay, uint8_t duration)
|
|||
controller_t *controller = controller_get_by_id(relay->controller_id);
|
||||
if(!controller)
|
||||
{
|
||||
LOG_ERROR("couldn't find controller\n");
|
||||
LOGGER_ERR("couldn't find controller\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -172,7 +172,7 @@ command_pulse(relay_t *relay, uint8_t duration)
|
|||
// finish writing
|
||||
if (mpack_writer_destroy(&writer) != mpack_ok)
|
||||
{
|
||||
LOG_ERROR("an error occurred encoding the data");
|
||||
LOGGER_ERR("an error occurred encoding the data");
|
||||
controller_free(controller);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
63
src/config.c
63
src/config.c
|
|
@ -10,40 +10,69 @@ config_t global_config;
|
|||
(ini_array_match(SECTION, disp->append_to, '.', disp->format) && \
|
||||
ini_string_match_ii(KEY, disp->data, disp->format))
|
||||
|
||||
int
|
||||
static int
|
||||
config_load_log_level(IniDispatch *disp, config_t *config)
|
||||
{
|
||||
if(strcasecmp(disp->value, "trace") == 0)
|
||||
{
|
||||
config->log_level = LOG_LEVEL_TRACE;
|
||||
return 0;
|
||||
}
|
||||
if(strcasecmp(disp->value, "debug") == 0)
|
||||
{
|
||||
config->log_level = LOG_LEVEL_DEBUG;
|
||||
setlogmask(LOG_UPTO(LOG_DEBUG));
|
||||
config->log_level = LOG_DEBUG;
|
||||
return 0;
|
||||
}
|
||||
if(strcasecmp(disp->value, "info") == 0)
|
||||
{
|
||||
config->log_level = LOG_LEVEL_INFO;
|
||||
setlogmask(LOG_UPTO(LOG_INFO));
|
||||
config->log_level = LOG_INFO;
|
||||
return 0;
|
||||
}
|
||||
if(strcasecmp(disp->value, "warn") == 0)
|
||||
if(strcasecmp(disp->value, "notice") == 0)
|
||||
{
|
||||
config->log_level = LOG_LEVEL_WARN;
|
||||
setlogmask(LOG_UPTO(LOG_NOTICE));
|
||||
config->log_level = LOG_NOTICE;
|
||||
return 0;
|
||||
}
|
||||
if(strcasecmp(disp->value, "error") == 0)
|
||||
if(strcasecmp(disp->value, "warning") == 0)
|
||||
{
|
||||
config->log_level = LOG_LEVEL_ERROR;
|
||||
setlogmask(LOG_UPTO(LOG_WARNING));
|
||||
config->log_level = LOG_WARNING;
|
||||
return 0;
|
||||
}
|
||||
if(strcasecmp(disp->value, "fatal") == 0)
|
||||
if(strcasecmp(disp->value, "err") == 0)
|
||||
{
|
||||
config->log_level = LOG_LEVEL_FATAL;
|
||||
setlogmask(LOG_UPTO(LOG_ERR));
|
||||
config->log_level = LOG_ERR;
|
||||
return 0;
|
||||
}
|
||||
LOG_WARN("invalid log-level '%s'\n", disp->value);
|
||||
if(strcasecmp(disp->value, "crit") == 0)
|
||||
{
|
||||
setlogmask(LOG_UPTO(LOG_CRIT));
|
||||
config->log_level = LOG_CRIT;
|
||||
return 0;
|
||||
}
|
||||
if(strcasecmp(disp->value, "emerg") == 0)
|
||||
{
|
||||
setlogmask(LOG_UPTO(LOG_EMERG));
|
||||
config->log_level = LOG_EMERG;
|
||||
return 0;
|
||||
}
|
||||
LOGGER_WARNING("invalid log-level '%s'\n", disp->value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
config_load_log_file(IniDispatch *disp, config_t *config)
|
||||
{
|
||||
if(strcasecmp(disp->value, "stdout") == 0)
|
||||
{
|
||||
config->log_file = stdout;
|
||||
return 0;
|
||||
}
|
||||
if(strcasecmp(disp->value, "stderr") == 0)
|
||||
{
|
||||
config->log_file = stderr;
|
||||
return 0;
|
||||
}
|
||||
config->log_file = fopen(disp->value, "a+");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -98,6 +127,10 @@ config_load(IniDispatch *disp, void *config_void)
|
|||
{
|
||||
return config_load_log_level(disp, config);
|
||||
}
|
||||
if(CONFINI_IS_KEY("core", "log-file"))
|
||||
{
|
||||
return config_load_log_file(disp, config);
|
||||
}
|
||||
if(CONFINI_IS_KEY("core", "server-port"))
|
||||
{
|
||||
config->server_port = atoi(disp->value);
|
||||
|
|
|
|||
|
|
@ -33,11 +33,11 @@ database_migrate()
|
|||
switch(version_num)
|
||||
{
|
||||
case 0:
|
||||
LOG_INFO("migrating LEVEL 0\n");
|
||||
LOGGER_INFO("migrating LEVEL 0\n");
|
||||
rc = sqlite3_exec(global_database, (const char *)sql_migration_0_sql, NULL, NULL, &err_msg);
|
||||
if(rc != 0)
|
||||
{
|
||||
LOG_FATAL("couldn't migrate LEVEL 0 (%s)\n", err_msg);
|
||||
LOGGER_CRIT("couldn't migrate LEVEL 0 (%s)\n", err_msg);
|
||||
break;
|
||||
}
|
||||
new_version_num = 1;
|
||||
|
|
@ -58,7 +58,7 @@ database_migrate()
|
|||
rc = sqlite3_step(stmt);
|
||||
if (rc != SQLITE_DONE)
|
||||
{
|
||||
LOG_FATAL("couldn't write new schema version\n");
|
||||
LOGGER_CRIT("couldn't write new schema version\n");
|
||||
}
|
||||
|
||||
sqlite3_finalize(stmt);
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ endpoint_func_not_found(struct mg_connection *nc, struct http_message *hm, endpo
|
|||
}
|
||||
else
|
||||
{
|
||||
LOG_DEBUG("404 file not found\n");
|
||||
LOGGER_DEBUG("404 file not found\n");
|
||||
response->status_code = 404;
|
||||
response->content_type = global_config.not_found_content_type;
|
||||
response->content_length = strlen(global_config.not_found_content);
|
||||
|
|
@ -84,7 +84,7 @@ endpoint_response_json(endpoint_response_t *response, int status_code, const cJS
|
|||
}
|
||||
}
|
||||
|
||||
LOG_ERROR("failed to print schedule json\n");
|
||||
LOGGER_ERR("failed to print schedule json\n");
|
||||
|
||||
static const char content[] = "failed to print json";
|
||||
endpoint_response_text(response, status_code, content, STRLEN(content));
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue