]> mj.ucw.cz Git - libucw.git/commitdiff
Logging: Add log_configured() to set up the default log stream as configured.
authorMartin Mares <mj@ucw.cz>
Mon, 16 Feb 2009 22:59:23 +0000 (23:59 +0100)
committerMartin Mares <mj@ucw.cz>
Mon, 16 Feb 2009 22:59:23 +0000 (23:59 +0100)
ucw/log-conf.c
ucw/log.h

index f811a5865acdd6dd151965db921cb634d7df9980..47feceae23948b7f93a991077192b3c95502e4db 100644 (file)
@@ -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"
index 9773f4cabd50a2ce9ab3a3b66945cf4e06dba3f7..acab80591003414e25945c2c6319f1cbc78c56cf 100644 (file)
--- 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.