From 1e00d0fed7c27a7b668204f8d749f01d501ea649 Mon Sep 17 00:00:00 2001 From: mansetagunj Date: Sat, 17 Mar 2018 23:36:43 -0600 Subject: [PATCH] implementing and using reading configuration file data --- Project1/src/logger_task.c | 15 +++++++++++++-- Project1/src/main_task.c | 6 ++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Project1/src/logger_task.c b/Project1/src/logger_task.c index bfaa28e..b0489a6 100644 --- a/Project1/src/logger_task.c +++ b/Project1/src/logger_task.c @@ -16,6 +16,7 @@ #include "main_task.h" #include "logger_task.h" #include "error_data.h" +#include "readConfiguration.h" #define LOG_DIR "./log/" #define __LOG_PATH(x) LOG_DIR ## x @@ -143,8 +144,18 @@ void* logger_task_callback(void *threadparam) { LOG_STDOUT(INFO "LOGGER TASK STARTED\n"); - //FILE * fp = logger_task_file_init((char*)threadparam); - FILE * fp = logger_task_file_init("project1.log"); + char *filename = configdata_getLogpath(); + FILE *fp; + if(filename) + { + fp = logger_task_file_init(filename); + } + else + { + LOG_STDOUT(WARNING "No filename found from config file\n"); + fp = logger_task_file_init("project1.log"); + } + if(NULL == fp) { LOG_STDOUT(ERROR "LOGGER TASK LOG FILE INIT FAIL\n"); diff --git a/Project1/src/main_task.c b/Project1/src/main_task.c index 812950e..9aa90c4 100644 --- a/Project1/src/main_task.c +++ b/Project1/src/main_task.c @@ -21,6 +21,7 @@ #include "my_signals.h" #include "posixTimer.h" #include "common_helper.h" +#include "readConfiguration.h" #define MQ_MAINTASK_NAME "/maintask_queue" @@ -221,6 +222,10 @@ int main_task_entry() return ret; } + ret = configdata_setup(); + if(ret) + LOG_STDOUT(ERROR "Could not setup data from config file\n"); + /* Mutex init */ pthread_mutex_init(&aliveState_lock, NULL); @@ -296,6 +301,7 @@ int main_task_entry() pthread_mutex_destroy(&aliveState_lock); + configdata_flush(); LOG_STDOUT(INFO "GOODBYE CRUEL WORLD!!!\n");