From: Pavel Charvat Date: Thu, 18 Feb 2010 15:12:15 +0000 (+0100) Subject: libucw: Implemented Loging.Stream.FileDesc. X-Git-Tag: holmes-import~11 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=461d9795c2f743e4319b83f4dfff90d95d4a2dee;p=libucw.git libucw: Implemented Loging.Stream.FileDesc. --- diff --git a/cf/libucw b/cf/libucw index 7c061ec4..e6318c25 100644 --- a/cf/libucw +++ b/cf/libucw @@ -187,6 +187,9 @@ Logging { # # Escape sequences for current date and time as described in strftime(3) can be used. # FileName log/test-%Y%m%d # +# # If you need to log to stderr or another already opened descriptor, you can specify its number. +# FileDesc 2 +# # # Instead of a file, a syslog facility can be specified. See syslog(3) for an explanation. # SyslogFacility daemon # diff --git a/ucw/log-conf.c b/ucw/log-conf.c index d0afece0..26d7d5c4 100644 --- a/ucw/log-conf.c +++ b/ucw/log-conf.c @@ -26,6 +26,7 @@ struct stream_config { cnode n; char *name; char *file_name; + int file_desc; char *syslog_facility; u32 levels; clist types; // simple_list of names @@ -53,6 +54,7 @@ stream_init(void *ptr) struct stream_config *c = ptr; c->levels = ~0U; + c->file_desc = -1; return NULL; } @@ -102,6 +104,7 @@ static struct cf_section stream_config = { #define P(x) PTR_TO(struct stream_config, x) CF_STRING("Name", P(name)), CF_STRING("FileName", P(file_name)), + CF_INT("FileDesc", P(file_desc)), CF_STRING("SyslogFacility", P(syslog_facility)), CF_BITMAP_LOOKUP("Levels", P(levels), level_names), CF_LIST("Types", P(types), &cf_string_list_config), @@ -293,6 +296,8 @@ do_new_configured(struct stream_config *c) if (c->file_name) ls = log_new_file(c->file_name, (c->stderr_follows ? FF_FD2_FOLLOWS : 0)); + else if (c->file_desc >= 0) + ls = log_new_fd(c->file_desc, (c->stderr_follows ? FF_FD2_FOLLOWS : 0)); else if (c->syslog_facility) ls = log_new_syslog(c->syslog_facility, (c->syslog_pids ? LOG_PID : 0)); else