fix: logger

This commit is contained in:
Tobias Reisinger 2020-04-24 15:08:26 +02:00
parent 61e025343d
commit db3bcaf7d1
28 changed files with 200 additions and 180 deletions

14
main.c
View file

@ -32,7 +32,7 @@ static struct pollfd poll_fds[POLL_FDS_COUNT];
static void
terminate(int signum)
{
LOG_INFO("terminating controller (%d)", signum);
LOG_INFO("terminating controller (%d)\n", signum);
for(int i = 0; i < POLL_FDS_COUNT; ++i)
{
@ -69,18 +69,20 @@ main(int argc, const char** argv)
/******************** LOAD CONFIG ********************/
global_config.file = "controller.ini";
global_config.database = "controller_db.lmdb";
global_config.log_level = LOG_LEVEL_INFO;
helpers_parse_cli(argc, argv, &global_config);
FILE * const ini_file = fopen(global_config.file, "rb");
if(ini_file == NULL)
{
LOG_FATAL("config file '%s' was not found", global_config.file);
LOG_FATAL("config file '%s' was not found\n", global_config.file);
exit(1);
}
if(load_ini_file( ini_file, INI_DEFAULT_FORMAT, NULL, helper_load_config, &global_config))
{
LOG_FATAL("unable to parse ini file");
LOG_FATAL("unable to parse ini file\n");
exit(1);
}
@ -88,7 +90,7 @@ main(int argc, const char** argv)
if(sizeof(time_t) < 8)
{
LOG_WARN("this system is not using 8-bit time");
LOG_WARN("this system is not using 8-bit time\n");
}
/******************** SETUP DATABASE AND THIS CONTROLLER ********************/
@ -127,10 +129,10 @@ main(int argc, const char** argv)
/* Open STREAMS device. */
poll_fds[POLL_FDS_DISCOVERY].fd = fd_discovery;
poll_fds[POLL_FDS_DISCOVERY].events = POLLIN;
LOG_DEBUG("setup fd_discovery as %i on index %i", fd_discovery, POLL_FDS_DISCOVERY);
LOG_DEBUG("setup fd_discovery as %i on index %i\n", fd_discovery, POLL_FDS_DISCOVERY);
poll_fds[POLL_FDS_COMMAND].fd = fd_command;
poll_fds[POLL_FDS_COMMAND].events = POLLIN;
LOG_DEBUG("setup fd_command as %i on index %i", fd_command, POLL_FDS_COMMAND);
LOG_DEBUG("setup fd_command as %i on index %i\n", fd_command, POLL_FDS_COMMAND);
/******************** CHECK FOR TESTING RUN ********************/