Add some simple logging facilities.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@2350 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
34
kdc/log.c
Normal file
34
kdc/log.c
Normal file
@@ -0,0 +1,34 @@
|
||||
#include "kdc_locl.h"
|
||||
RCSID("$Id$");
|
||||
|
||||
static char *logfile = "kdc.log";
|
||||
static int loglevel = 17;
|
||||
|
||||
void
|
||||
kdc_log(int level, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
FILE *f;
|
||||
char buf[128];
|
||||
char *s;
|
||||
|
||||
if(level > loglevel)
|
||||
return;
|
||||
|
||||
if(logfile == NULL)
|
||||
return;
|
||||
f = fopen(logfile, "a");
|
||||
if(f == NULL)
|
||||
return;
|
||||
|
||||
va_start(ap, fmt);
|
||||
vasprintf(&s, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
if(s == NULL)
|
||||
return;
|
||||
strftime(buf, sizeof(buf), "%d-%b-%Y %H:%M:%S", localtime(&kdc_time));
|
||||
fprintf(f, "%s %s\n", buf, s);
|
||||
fclose(f);
|
||||
free(s);
|
||||
}
|
Reference in New Issue
Block a user