From: Martin Mares Date: Mon, 16 Feb 2009 22:59:23 +0000 (+0100) Subject: Logging: Add log_configured() to set up the default log stream as configured. X-Git-Tag: holmes-import~66 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=e985b494fff0a0caf7703ad2953408aa830ccbde;p=libucw.git Logging: Add log_configured() to set up the default log stream as configured. --- 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.