X-Git-Url: http://www.dolda2000.com/gitweb/?p=ashd.git;a=blobdiff_plain;f=lib%2Flog.c;h=bd07d8d13cb61d14ff7af3b5826695f10f50bd31;hp=81f52ba0ada32fd33ba2bc1339bc9b7fc1d7d8d4;hb=d341283f757e188a52aedae7d715e201f2a430c2;hpb=d185ffb9d36ed23e28b632b7a17a24e323343c6b diff --git a/lib/log.c b/lib/log.c index 81f52ba..bd07d8d 100644 --- a/lib/log.c +++ b/lib/log.c @@ -25,13 +25,24 @@ #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); @@ -44,6 +55,8 @@ void flog(int level, char *format, ...) void opensyslog(void) { + if(!inited) + initlog(); openlog("ashd", 0, LOG_DAEMON); tostderr = 0; tosyslog = 1;