From e985b494fff0a0caf7703ad2953408aa830ccbde Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Mon, 16 Feb 2009 23:59:23 +0100 Subject: [PATCH] Logging: Add log_configured() to set up the default log stream as configured. --- ucw/log-conf.c | 10 ++++++++++ ucw/log.h | 3 +++ 2 files changed, 13 insertions(+) diff --git a/ucw/log-conf.c b/ucw/log-conf.c index f811a586..47feceae 100644 --- a/ucw/log-conf.c +++ b/ucw/log-conf.c @@ -167,6 +167,16 @@ log_new_configured(const char *name) return do_new_configured(c); } +void +log_configured(const char *name) +{ + struct log_stream *ls = log_new_configured(name); + struct log_stream *def = log_stream_by_flags(0); + log_rm_substream(def, NULL); + log_add_substream(def, ls); + log_close_stream(ls); +} + #ifdef TEST #include "ucw/getopt.h" diff --git a/ucw/log.h b/ucw/log.h index 9773f4ca..acab8059 100644 --- a/ucw/log.h +++ b/ucw/log.h @@ -231,6 +231,9 @@ int log_syslog_facility_exists(const char *facility); /** Open a log stream configured under the specified name and increase its use count. **/ struct log_stream *log_new_configured(const char *name); +/** Open a log stream configured under the specified name and use it as the default destination. **/ +void log_configured(const char *name); + /** * Verify that a stream called @name was configured. If it wasn't, return an error * message. This is intended to be used in configuration commit hooks. -- 2.39.2