add: logging
fix: rename branch
This commit is contained in:
parent
9e5718db43
commit
2f9be90ec1
5 changed files with 63 additions and 49 deletions
src/models
|
@ -186,6 +186,11 @@ controller_free_list(controller_t **controllers)
|
|||
cJSON*
|
||||
controller_to_json(controller_t *controller)
|
||||
{
|
||||
char uuid_str[UUID_STR_LEN];
|
||||
uuid_unparse(controller->uid, uuid_str);
|
||||
|
||||
LOGGER_DEBUG("JSONifying controller %s\n", uuid_str);
|
||||
|
||||
cJSON *json = cJSON_CreateObject();
|
||||
|
||||
cJSON *json_name = cJSON_CreateString(controller->name);
|
||||
|
@ -196,8 +201,6 @@ controller_to_json(controller_t *controller)
|
|||
}
|
||||
cJSON_AddItemToObject(json, "name", json_name);
|
||||
|
||||
char uuid_str[UUID_STR_LEN];
|
||||
uuid_unparse(controller->uid, uuid_str);
|
||||
cJSON *json_id = cJSON_CreateString(uuid_str);
|
||||
if(json_name == NULL)
|
||||
{
|
||||
|
@ -253,6 +256,7 @@ controller_to_json(controller_t *controller)
|
|||
controller_t*
|
||||
controller_get_by_id(int id)
|
||||
{
|
||||
LOGGER_DEBUG("getting controller [id=%d] from database\n", id);
|
||||
sqlite3_stmt *stmt;
|
||||
|
||||
sqlite3_prepare_v2(global_database, "SELECT * FROM controllers WHERE id = ?1;", -1, &stmt, NULL);
|
||||
|
@ -269,6 +273,9 @@ controller_get_by_id(int id)
|
|||
controller_t*
|
||||
controller_get_by_uid(uuid_t uid)
|
||||
{
|
||||
char uuid_str[UUID_STR_LEN];
|
||||
uuid_unparse(uid, uuid_str);
|
||||
LOGGER_DEBUG("getting controller [uid=%s] from database\n", uuid_str);
|
||||
sqlite3_stmt *stmt;
|
||||
|
||||
sqlite3_prepare_v2(global_database, "SELECT * FROM controllers WHERE uid = ?1;", -1, &stmt, NULL);
|
||||
|
@ -285,6 +292,7 @@ controller_get_by_uid(uuid_t uid)
|
|||
controller_t**
|
||||
controller_get_all()
|
||||
{
|
||||
LOGGER_DEBUG("getting all controllers from database\n");
|
||||
sqlite3_stmt *stmt;
|
||||
|
||||
sqlite3_prepare_v2(global_database, "SELECT * FROM controllers;", -1, &stmt, NULL);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue