X-Git-Url: http://git.dolda2000.com/gitweb/?a=blobdiff_plain;f=lib%2Flog.c;fp=lib%2Flog.c;h=b87d4f656aab0c8dde73ead6e20856b830e540fa;hb=ddf9919274745e46fc8005f8a86d9b58500b628e;hp=0000000000000000000000000000000000000000;hpb=f0bbedf750f1530ec05bf2b8122479c924bbf2fe;p=ashd.git diff --git a/lib/log.c b/lib/log.c new file mode 100644 index 0000000..b87d4f6 --- /dev/null +++ b/lib/log.c @@ -0,0 +1,47 @@ +/* + ashd - A Sane HTTP Daemon + Copyright (C) 2008 Fredrik Tolf + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include +#include +#include +#include + +#include + +static int tostderr = 1, tosyslog = 0; + +void flog(int level, char *format, ...) +{ + va_list args; + + va_start(args, format); + if(tostderr) { + vfprintf(stderr, format, args); + fprintf(stderr, "\n"); + } else if(tosyslog) { + vsyslog(level, format, args); + } + va_end(args); +} + +void opensyslog(void) +{ + openlog("ashd", 0, LOG_DAEMON); + tostderr = 0; + tosyslog = 1; +}