*/
int (*write_to_log)(log_id_t log_id, log_priority prio, const char *tag, const char *msg) = __write_to_log_null;
pthread_mutex_t log_init_lock = PTHREAD_MUTEX_INITIALIZER;
-extern void __dlog_init_pipe();
-extern void __dlog_init_android();
+extern void __dlog_init_pipe(const struct log_config *conf);
+extern void __dlog_init_android(const struct log_config *conf);
bool limiter;
bool dynamic_config;
return 0;
if (!strcmp(backend, "pipe"))
- __dlog_init_pipe();
+ __dlog_init_pipe(config);
else if (!strcmp(backend, "logger"))
- __dlog_init_android();
+ __dlog_init_android(config);
else
return 0;
* @brief Initialize the backend
* @details Prepares the backend for proper and fruitful work
*/
-void __dlog_init_android()
+void __dlog_init_android(const struct log_config *conf)
{
- struct log_config conf;
log_id_t buf_id;
- if (log_config_read(&conf) < 0)
- return;
-
for (buf_id = 0; buf_id < LOG_ID_MAX; ++buf_id) {
- int ret = logger_open_buffer_from_config(buf_id, &conf, O_WRONLY, &log_fds[buf_id]);
+ int ret = logger_open_buffer_from_config(buf_id, conf, O_WRONLY, &log_fds[buf_id]);
if (ret < 0)
goto failure; //LCOV_EXCL_LINE
continue;
}
write_to_log = __write_to_log_android;
- goto cleanup;
+ return;
failure:
for (buf_id = 0; buf_id < LOG_ID_MAX; buf_id++) { // LCOV_EXCL_LINE
if (log_fds[buf_id] >= 0) // LCOV_EXCL_LINE
close(log_fds[buf_id]); // LCOV_EXCL_LINE
}
-cleanup:
- log_config_free(&conf);
- return;
}
* @brief Initialize the backend
* @details Prepares the backend for proper and fruitful work
*/
-void __dlog_init_pipe()
+void __dlog_init_pipe(const struct log_config *conf)
{
- struct log_config conf;
int i;
/*
*/
signal(SIGPIPE, SIG_IGN);
- if (log_config_read(&conf) < 0)
- return; // LCOV_EXCL_LINE
-
for (i = 0; i < LOG_ID_MAX; ++i) {
char conf_key[MAX_CONF_KEY_LEN];
snprintf(conf_key, sizeof(conf_key), "%s_write_sock", log_name_by_id(i));
- const char * conf_val = log_config_get(&conf, conf_key);
+ const char * conf_val = log_config_get(conf, conf_key);
if (!conf_val) {
syslog_critical_failure("DLOG CRITICAL FAILURE: DLog config lacks the \"%s\" entry!", conf_key); // LCOV_EXCL_LINE
- log_config_free(&conf); // LCOV_EXCL_LINE
return; // LCOV_EXCL_LINE
}
snprintf(log_pipe_path[i], PATH_MAX, "%s", conf_val);
}
- log_config_free(&conf);
write_to_log = __write_to_log_pipe;
}