Skip to content

Commit

Permalink
implementing and using reading configuration file data
Browse files Browse the repository at this point in the history
  • Loading branch information
mansetagunj committed Mar 18, 2018
1 parent 1cd4ebc commit 1e00d0f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
15 changes: 13 additions & 2 deletions Project1/src/logger_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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");
Expand Down
6 changes: 6 additions & 0 deletions Project1/src/main_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "my_signals.h"
#include "posixTimer.h"
#include "common_helper.h"
#include "readConfiguration.h"


#define MQ_MAINTASK_NAME "/maintask_queue"
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -296,6 +301,7 @@ int main_task_entry()

pthread_mutex_destroy(&aliveState_lock);

configdata_flush();

LOG_STDOUT(INFO "GOODBYE CRUEL WORLD!!!\n");

Expand Down

0 comments on commit 1e00d0f

Please sign in to comment.