Use krb5_log* functions.

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@2665 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Johan Danielsson
1997-08-01 14:48:06 +00:00
parent 584eb44cb9
commit 24868107ef

View File

@@ -39,53 +39,40 @@
#include "kdc_locl.h" #include "kdc_locl.h"
RCSID("$Id$"); RCSID("$Id$");
extern char *logfile;
extern int loglevel; extern int loglevel;
static krb5_log_facility *logf;
char* char*
kdc_log_msg_va(int level, const char *fmt, va_list ap) kdc_log_msg_va(krb5_context context, int level, const char *fmt, va_list ap)
{ {
FILE *f; char *msg;
char *s;
if(level > loglevel) if(level > loglevel)
return NULL; return NULL;
if(logf == NULL)
krb5_openlog(context, "kdc", &logf);
if(logfile == NULL) krb5_vlog_msg(context, logf, &msg, fmt, ap);
return NULL; return msg;
f = fopen(logfile, "a");
if(f == NULL)
return NULL;
vasprintf(&s, fmt, ap);
if(s){
char buf[128];
strftime(buf, sizeof(buf), "%d-%b-%Y %H:%M:%S", localtime(&kdc_time));
fprintf(f, "%s %s\n", buf, s);
}
fclose(f);
return s;
} }
char* char*
kdc_log_msg(int level, const char *fmt, ...) kdc_log_msg(krb5_context context, int level, const char *fmt, ...)
{ {
va_list ap; va_list ap;
char *s; char *s;
va_start(ap, fmt); va_start(ap, fmt);
s = kdc_log_msg_va(level, fmt, ap); s = kdc_log_msg_va(context, level, fmt, ap);
va_end(ap); va_end(ap);
return s; return s;
} }
void void
kdc_log(int level, const char *fmt, ...) kdc_log(krb5_context context, int level, const char *fmt, ...)
{ {
va_list ap; va_list ap;
char *s; char *s;
va_start(ap, fmt); va_start(ap, fmt);
s = kdc_log_msg_va(level, fmt, ap); s = kdc_log_msg_va(context, level, fmt, ap);
if(s) free(s); if(s) free(s);
va_end(ap); va_end(ap);
} }