diff options
-rw-r--r-- | include/osmocom/core/logging.h | 1 | ||||
-rw-r--r-- | src/logging.c | 20 |
2 files changed, 21 insertions, 0 deletions
diff --git a/include/osmocom/core/logging.h b/include/osmocom/core/logging.h index fa3365ad..1d57e22c 100644 --- a/include/osmocom/core/logging.h +++ b/include/osmocom/core/logging.h @@ -203,6 +203,7 @@ struct log_target *log_target_create_file(const char *fname); struct log_target *log_target_create_syslog(const char *ident, int option, int facility); int log_target_file_reopen(struct log_target *tgt); +int log_targets_reopen(void); void log_add_target(struct log_target *target); void log_del_target(struct log_target *target); diff --git a/src/logging.c b/src/logging.c index eab8bdf8..ffe6ecff 100644 --- a/src/logging.c +++ b/src/logging.c @@ -597,6 +597,26 @@ int log_target_file_reopen(struct log_target *target) return 0; } +/*! \brief close and re-open a log file (for log file rotation) */ +int log_targets_reopen(void) +{ + struct log_target *tar; + int rc = 0; + + llist_for_each_entry(tar, &osmo_log_target_list, entry) { + switch (tar->type) { + case LOG_TGT_TYPE_FILE: + if (log_target_file_reopen(tar) < 0) + rc = -1; + break; + default: + break; + } + } + + return rc; +} + /*! \brief Generates the logging command string for VTY * \param[in] unused_info Deprecated parameter, no longer used! */ |