X-Git-Url: http://www.dolda2000.com/gitweb/?a=blobdiff_plain;f=lib%2Flog.c;h=bd07d8d13cb61d14ff7af3b5826695f10f50bd31;hb=2824afabef34b9bd0aa41644c7da1858d1532da8;hp=b87d4f656aab0c8dde73ead6e20856b830e540fa;hpb=ddf9919274745e46fc8005f8a86d9b58500b628e;p=ashd.git diff --git a/lib/log.c b/lib/log.c index b87d4f6..bd07d8d 100644 --- a/lib/log.c +++ b/lib/log.c @@ -21,14 +21,28 @@ #include #include +#ifdef HAVE_CONFIG_H +#include +#endif #include +#include +static int inited = 0; static int tostderr = 1, tosyslog = 0; +static void initlog(void) +{ + inited = 1; + if(getenv("ASHD_USESYSLOG") != NULL) + opensyslog(); +} + void flog(int level, char *format, ...) { va_list args; + if(!inited) + initlog(); va_start(args, format); if(tostderr) { vfprintf(stderr, format, args); @@ -41,6 +55,8 @@ void flog(int level, char *format, ...) void opensyslog(void) { + if(!inited) + initlog(); openlog("ashd", 0, LOG_DAEMON); tostderr = 0; tosyslog = 1;