From 3d7245c16c34d958371f42d95307b79dedef5629 Mon Sep 17 00:00:00 2001 From: Tobias Reisinger Date: Fri, 14 Aug 2020 23:48:57 +0200 Subject: [PATCH] add: more debug logs --- CMakeLists.txt | 2 +- src/cache.c | 1 + src/endpoints/api_v1_controllers_STR_relays_INT.c | 4 ++-- src/models/controller.c | 1 + src/models/relay.c | 1 + src/models/schedule.c | 2 ++ src/models/tag.c | 2 ++ 7 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d7632e3..5c96106 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 3.7) project(core - VERSION 0.2.8 + VERSION 0.2.9 LANGUAGES C) add_executable(core src/main.c) diff --git a/src/cache.c b/src/cache.c index 50bfbc2..fe968d5 100644 --- a/src/cache.c +++ b/src/cache.c @@ -66,6 +66,7 @@ cache_insert_value(char *key, char *value) static void cache_invalidate(char *key) { + LOGGER_DEBUG("invalidating %s\n", key); sqlite3_stmt *stmt; int rc; diff --git a/src/endpoints/api_v1_controllers_STR_relays_INT.c b/src/endpoints/api_v1_controllers_STR_relays_INT.c index 082b723..9726d2d 100644 --- a/src/endpoints/api_v1_controllers_STR_relays_INT.c +++ b/src/endpoints/api_v1_controllers_STR_relays_INT.c @@ -168,7 +168,7 @@ api_v1_controllers_STR_relays_INT_PUT(struct mg_connection *nc, struct http_mess schedule_free(relay->schedules[schedule_position]); relay->schedules[schedule_position] = schedule_get_by_uid_or_off(target_uid); - LOGGER_DEBUG("new schedule[%d]: %s\n", schedule_position, relay->schedules[schedule_position]); + LOGGER_DEBUG("new schedule[%d]: %s\n", schedule_position, relay->schedules[schedule_position]->name); ++schedule_position; } @@ -197,7 +197,7 @@ api_v1_controllers_STR_relays_INT_PUT(struct mg_connection *nc, struct http_mess return; } relay->schedules[day_of_week] = schedule_get_by_uid_or_off(target_uid); - LOGGER_DEBUG("new active schedule: %s\n", relay->schedules[day_of_week]); + LOGGER_DEBUG("new active schedule: %s\n", relay->schedules[day_of_week]->name); } } diff --git a/src/models/controller.c b/src/models/controller.c index 401edc3..2c90e6b 100644 --- a/src/models/controller.c +++ b/src/models/controller.c @@ -13,6 +13,7 @@ static int db_update_insert(controller_t *controller, sqlite3_stmt *stmt) { + LOGGER_DEBUG("saving controller '%s' into database (id: %d)\n", controller->name, controller->id); int rc; sqlite3_bind_int(stmt, 1, controller->id); diff --git a/src/models/relay.c b/src/models/relay.c index ecb5e3a..2d8ed44 100644 --- a/src/models/relay.c +++ b/src/models/relay.c @@ -17,6 +17,7 @@ static int db_update_insert(relay_t *relay, sqlite3_stmt *stmt) { + LOGGER_DEBUG("saving relay '%s' into database (id: %d)\n", relay->name, relay->id); int rc; sqlite3_bind_int(stmt, 1, relay->id); diff --git a/src/models/schedule.c b/src/models/schedule.c index 01011b9..52ecba2 100644 --- a/src/models/schedule.c +++ b/src/models/schedule.c @@ -13,6 +13,8 @@ static int db_update_insert(schedule_t *schedule, sqlite3_stmt *stmt) { + LOGGER_DEBUG("saving schedule '%s' into database (id: %d)\n", schedule->name, schedule->id); + int rc; uint16_t *periods_blob = schedule_periods_to_blob(schedule); int blob_size = (int)sizeof(uint16_t) * ((periods_blob[0] * 2) + 1); diff --git a/src/models/tag.c b/src/models/tag.c index f86f08b..63615f1 100644 --- a/src/models/tag.c +++ b/src/models/tag.c @@ -10,6 +10,8 @@ int tag_save(int id, const char *tag) { + LOGGER_DEBUG("saving tag '%s' into database (id: %d)\n", tag, id); + int rc; sqlite3_stmt *stmt;