Config module: use printf_params() to print log messages
This commit is contained in:
@@ -302,7 +302,7 @@ configmodule_interface_t *load_configmodule(int argc,
|
|||||||
}
|
}
|
||||||
static configmodule_interface_t *cfgptr;
|
static configmodule_interface_t *cfgptr;
|
||||||
if (cfgptr)
|
if (cfgptr)
|
||||||
printf("ERROR: Call load_configmodule more than one time\n");
|
fprintf(stderr, "ERROR: Call load_configmodule more than one time\n");
|
||||||
|
|
||||||
// The macros are not thread safe print_params and similar
|
// The macros are not thread safe print_params and similar
|
||||||
cfgptr = calloc(sizeof(configmodule_interface_t), 1);
|
cfgptr = calloc(sizeof(configmodule_interface_t), 1);
|
||||||
@@ -369,8 +369,7 @@ configmodule_interface_t *load_configmodule(int argc,
|
|||||||
if (strstr(cfgparam,CONFIG_CMDLINEONLY) == NULL) {
|
if (strstr(cfgparam,CONFIG_CMDLINEONLY) == NULL) {
|
||||||
i=load_config_sharedlib(cfgptr);
|
i=load_config_sharedlib(cfgptr);
|
||||||
|
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
printf("[CONFIG] config module %s loaded\n",cfgmode);
|
|
||||||
int idx = config_paramidx_fromname(Config_Params, sizeofArray(Config_Params), CONFIGP_DEBUGFLAGS);
|
int idx = config_paramidx_fromname(Config_Params, sizeofArray(Config_Params), CONFIGP_DEBUGFLAGS);
|
||||||
Config_Params[idx].uptr = &(cfgptr->rtflags);
|
Config_Params[idx].uptr = &(cfgptr->rtflags);
|
||||||
idx = config_paramidx_fromname(Config_Params, sizeofArray(Config_Params), CONFIGP_TMPDIR);
|
idx = config_paramidx_fromname(Config_Params, sizeofArray(Config_Params), CONFIGP_TMPDIR);
|
||||||
@@ -387,7 +386,7 @@ configmodule_interface_t *load_configmodule(int argc,
|
|||||||
cfgptr->end = (configmodule_endfunc_t)nooptfunc;
|
cfgptr->end = (configmodule_endfunc_t)nooptfunc;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("[CONFIG] debug flags: 0x%08x\n", cfgptr->rtflags);
|
printf_params(cfgptr, "[CONFIG] debug flags: 0x%08x\n", cfgptr->rtflags);
|
||||||
|
|
||||||
if (modeparams != NULL) free(modeparams);
|
if (modeparams != NULL) free(modeparams);
|
||||||
|
|
||||||
@@ -413,7 +412,7 @@ void write_parsedcfg(configmodule_interface_t *cfgptr)
|
|||||||
cfgptr->status->num_write);
|
cfgptr->status->num_write);
|
||||||
}
|
}
|
||||||
if (cfgptr->write_parsedcfg != NULL) {
|
if (cfgptr->write_parsedcfg != NULL) {
|
||||||
printf("[CONFIG] calling config module write_parsedcfg function...\n");
|
printf_params(cfgptr, "[CONFIG] calling config module write_parsedcfg function...\n");
|
||||||
cfgptr->write_parsedcfg(cfgptr);
|
cfgptr->write_parsedcfg(cfgptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -425,12 +424,11 @@ void end_configmodule(configmodule_interface_t *cfgptr)
|
|||||||
if (cfgptr != NULL) {
|
if (cfgptr != NULL) {
|
||||||
write_parsedcfg(cfgptr);
|
write_parsedcfg(cfgptr);
|
||||||
if (cfgptr->end != NULL) {
|
if (cfgptr->end != NULL) {
|
||||||
printf ("[CONFIG] calling config module end function...\n");
|
printf_params(cfgptr, "[CONFIG] calling config module end function...\n");
|
||||||
cfgptr->end(cfgptr);
|
cfgptr->end(cfgptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_lock(&cfgptr->memBlocks_mutex);
|
pthread_mutex_lock(&cfgptr->memBlocks_mutex);
|
||||||
printf ("[CONFIG] free %u config value pointers\n",cfgptr->numptrs);
|
|
||||||
|
|
||||||
for(int i=0; i<cfgptr->numptrs ; i++) {
|
for(int i=0; i<cfgptr->numptrs ; i++) {
|
||||||
if (cfgptr->oneBlock[i].ptrs != NULL && cfgptr->oneBlock[i].ptrsAllocated== true && cfgptr->oneBlock[i].toFree) {
|
if (cfgptr->oneBlock[i].ptrs != NULL && cfgptr->oneBlock[i].ptrsAllocated== true && cfgptr->oneBlock[i].toFree) {
|
||||||
|
|||||||
@@ -461,13 +461,11 @@ int config_libconfig_get(configmodule_interface_t *cfg, paramdef_t *cfgoptions,
|
|||||||
} /* switch on param type */
|
} /* switch on param type */
|
||||||
|
|
||||||
if( notfound == 1) {
|
if( notfound == 1) {
|
||||||
printf("[LIBCONFIG] %s not found in %s ", cfgpath,libconfig_privdata.configfile );
|
fprintf(stderr, "[LIBCONFIG] %s not found in %s ", cfgpath, libconfig_privdata.configfile);
|
||||||
|
|
||||||
if ( (cfgoptions[i].paramflags & PARAMFLAG_MANDATORY) != 0) {
|
if ( (cfgoptions[i].paramflags & PARAMFLAG_MANDATORY) != 0) {
|
||||||
fatalerror=1;
|
fatalerror=1;
|
||||||
printf(" mandatory parameter missing\n");
|
fprintf(stderr, " mandatory parameter missing\n");
|
||||||
} else {
|
|
||||||
printf("\n");
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (defval == 1) {
|
if (defval == 1) {
|
||||||
@@ -571,7 +569,7 @@ int config_libconfig_init(configmodule_interface_t *cfg)
|
|||||||
|
|
||||||
const char *incp = config_get_include_dir (&(libconfig_privdata.cfg)) ;
|
const char *incp = config_get_include_dir (&(libconfig_privdata.cfg)) ;
|
||||||
|
|
||||||
printf("[LIBCONFIG] Path for include directive set to: %s\n", (incp!=NULL)?incp:"libconfig defaults");
|
printf_params(cfg, "[LIBCONFIG] Path for include directive set to: %s\n", (incp != NULL) ? incp : "libconfig defaults");
|
||||||
/* set convertion option to allow integer to float conversion*/
|
/* set convertion option to allow integer to float conversion*/
|
||||||
config_set_auto_convert (&(libconfig_privdata.cfg), CONFIG_TRUE);
|
config_set_auto_convert (&(libconfig_privdata.cfg), CONFIG_TRUE);
|
||||||
/* Read the file. If there is an error, report it and exit. */
|
/* Read the file. If there is an error, report it and exit. */
|
||||||
@@ -582,7 +580,7 @@ int config_libconfig_init(configmodule_interface_t *cfg)
|
|||||||
config_error_line(&(libconfig_privdata.cfg)),
|
config_error_line(&(libconfig_privdata.cfg)),
|
||||||
config_error_text(&(libconfig_privdata.cfg)));
|
config_error_text(&(libconfig_privdata.cfg)));
|
||||||
config_destroy(&(libconfig_privdata.cfg));
|
config_destroy(&(libconfig_privdata.cfg));
|
||||||
printf( "\n");
|
fprintf(stderr, "\n");
|
||||||
free(tmppath);
|
free(tmppath);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -623,11 +621,11 @@ void config_libconfig_write_parsedcfg(configmodule_interface_t *cfg)
|
|||||||
config_error_line(&(libconfig_privdata.runtcfg)),
|
config_error_line(&(libconfig_privdata.runtcfg)),
|
||||||
config_error_text(&(libconfig_privdata.runtcfg)));
|
config_error_text(&(libconfig_privdata.runtcfg)));
|
||||||
} else {
|
} else {
|
||||||
printf("[LIBCONFIG] file %s created successfully\n", cfg->status->debug_cfgname);
|
printf_params(cfg, "[LIBCONFIG] file %s created successfully\n", cfg->status->debug_cfgname);
|
||||||
}
|
}
|
||||||
free(fname);
|
free(fname);
|
||||||
} else {
|
} else {
|
||||||
printf("[LIBCONFIG] Cannot create config file after parsing: CONFIG_SAVERUNCFG flag not specified\n");
|
printf_params(cfg, "[LIBCONFIG] Cannot create config file after parsing: CONFIG_SAVERUNCFG flag not specified\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user