mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 21:23:58 +01:00
clean up sev_to_string hack in log.c
svn:r355
This commit is contained in:
parent
dbf3435cde
commit
6c9e3762b5
@ -3,43 +3,19 @@
|
||||
/* $Id$ */
|
||||
|
||||
#include "../or/or.h"
|
||||
#include "log.h"
|
||||
|
||||
/* FIXME this whole thing is hacked together. feel free to make it clean. */
|
||||
size_t sev_to_string(char *buf, int max, int severity) {
|
||||
assert(max > 20);
|
||||
|
||||
static const char *sev_to_string(int severity) {
|
||||
switch(severity) {
|
||||
case LOG_DEBUG:
|
||||
strcpy(buf,"debug");
|
||||
break;
|
||||
case LOG_INFO:
|
||||
strcpy(buf,"info");
|
||||
break;
|
||||
case LOG_NOTICE:
|
||||
strcpy(buf,"notice");
|
||||
break;
|
||||
case LOG_WARNING:
|
||||
strcpy(buf,"warn");
|
||||
break;
|
||||
case LOG_ERR:
|
||||
strcpy(buf,"err");
|
||||
break;
|
||||
case LOG_CRIT:
|
||||
strcpy(buf,"crit");
|
||||
break;
|
||||
case LOG_ALERT:
|
||||
strcpy(buf,"alert");
|
||||
break;
|
||||
case LOG_EMERG:
|
||||
strcpy(buf,"emerg");
|
||||
break;
|
||||
default:
|
||||
strcpy(buf,"UNKNOWN");
|
||||
break;
|
||||
case LOG_DEBUG: return "debug";
|
||||
case LOG_INFO: return "info";
|
||||
case LOG_NOTICE: return "notice";
|
||||
case LOG_WARNING: return "warn";
|
||||
case LOG_ERR: return "err";
|
||||
case LOG_CRIT: return "crit";
|
||||
case LOG_ALERT: return "alert";
|
||||
case LOG_EMERG: return "emerg";
|
||||
default: return "UNKNOWN";
|
||||
}
|
||||
|
||||
return strlen(buf)+1;
|
||||
}
|
||||
|
||||
static int loglevel = LOG_DEBUG;
|
||||
@ -59,9 +35,7 @@ logv(int severity, const char *funcname, const char *format, va_list ap)
|
||||
|
||||
t = time(NULL);
|
||||
strftime(buf, 200, "%b %d %H:%M:%S", localtime(&t));
|
||||
printf("%s.%.3ld ", buf, (long)now.tv_usec / 1000);
|
||||
sev_to_string(buf, 200, severity);
|
||||
printf("[%s] ", buf);
|
||||
printf("%s.%.3ld [%s] ", buf, (long)now.tv_usec / 1000, sev_to_string(severity));
|
||||
if (funcname)
|
||||
printf("%s(): ", funcname);
|
||||
vprintf(format,ap);
|
||||
|
Loading…
Reference in New Issue
Block a user