diff --git a/include/osmocom/core/application.h b/include/osmocom/core/application.h index 266fa9bb8..edf59ed4c 100644 --- a/include/osmocom/core/application.h +++ b/include/osmocom/core/application.h @@ -1,5 +1,7 @@ #pragma once +#include + /*! * \file application.h * Routines for helping with the osmocom application setup. @@ -15,6 +17,8 @@ struct log_target; extern struct log_target *osmo_stderr_target; void osmo_init_ignore_signals(void); -int osmo_init_logging(const struct log_info *); +int osmo_init_logging(const struct log_info *) + OSMO_DEPRECATED("use osmo_init_logging2() instead to avoid a NULL talloc ctx"); +int osmo_init_logging2(void *ctx, const struct log_info *log_info); int osmo_daemonize(void); diff --git a/src/application.c b/src/application.c index 2d237e2c1..d912eb72d 100644 --- a/src/application.c +++ b/src/application.c @@ -113,6 +113,11 @@ void osmo_init_ignore_signals(void) * creates the default (stderr) logging target. */ int osmo_init_logging(const struct log_info *log_info) +{ + return osmo_init_logging2(NULL, log_info); +} + +int osmo_init_logging2(void *ctx, const struct log_info *log_info) { static int logging_initialized = 0; @@ -120,7 +125,7 @@ int osmo_init_logging(const struct log_info *log_info) return -EEXIST; logging_initialized = 1; - log_init(log_info, NULL); + log_init(log_info, ctx); osmo_stderr_target = log_target_create_stderr(); if (!osmo_stderr_target) return -1;