diff --git a/src/backend.c b/src/backend.c index bff2917..6f20fc3 100644 --- a/src/backend.c +++ b/src/backend.c @@ -12,9 +12,11 @@ f2b_backend_create(f2b_config_section_t *config, const char *id) { assert(config != NULL); assert(config->type == t_backend); - f2b_config_find_param(config->param, BACKEND_LIBRARY_PARAM); - if (!param) + param = f2b_config_find_param(config->param, BACKEND_LIBRARY_PARAM); + if (!param) { + f2b_log_msg(log_error, "can't find '%s' param in backend config", BACKEND_LIBRARY_PARAM); return NULL; + } if ((backend = calloc(1, sizeof(f2b_backend_t))) == NULL) return NULL; @@ -64,6 +66,7 @@ f2b_backend_create(f2b_config_section_t *config, const char *id) { f2b_log_msg(log_error, "backend '%s' not fully configured", config->name); cleanup: + f2b_log_msg(log_error, "load error: %s", dlerror()); if (backend->h) { if (backend->cfg && backend->destroy) backend->destroy(backend->cfg); diff --git a/src/common.h b/src/common.h index b5a01be..0eefac2 100644 --- a/src/common.h +++ b/src/common.h @@ -7,8 +7,9 @@ #include #include #include -#include +#include #include +#include #include #include #include diff --git a/src/config.c b/src/config.c index a2fe832..0dc254f 100644 --- a/src/config.c +++ b/src/config.c @@ -40,7 +40,7 @@ f2b_config_parse_kv_pair(const char *src) { p = value + strlen(value); if (p > value) p--; /* step back at char before '\0' */ - while (p > value && isblank(*p)) + while (p > value && isspace(*p)) p--; p++, *p = '\0'; @@ -147,7 +147,7 @@ f2b_config_load(const char *path) { size_t linenum = 0; /* current line number in config */ if ((f = fopen(path, "r")) == NULL) { - f2b_log_msg(log_error, "can't open config file: %s: %s", path, strerror(errno)); + f2b_log_msg(log_error, "can't open config file '%s': %s", path, strerror(errno)); return NULL; } diff --git a/src/log.c b/src/log.c index 1d443d7..5482ad7 100644 --- a/src/log.c +++ b/src/log.c @@ -1,7 +1,3 @@ -#include -#include -#include - #include "common.h" #include "log.h" @@ -26,9 +22,12 @@ void f2b_log_msg(log_msgtype_t l, const char *fmt, ...) { return; va_start(args, fmt); - snprintf(msg, sizeof(msg), fmt, args); + vsnprintf(msg, sizeof(msg), fmt, args); va_end(args); - printf(line, LOGLINE_MAX, "[%s] %s", loglevels[l], msg); + snprintf(line, LOGLINE_MAX, "[%s] %s", loglevels[l], msg); + /* TODO */ + fputs(line, stderr); + fputc('\n', stderr); return; }