summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2003-06-25 04:47:54 +0000
committerRoger Dingledine <arma@torproject.org>2003-06-25 04:47:54 +0000
commit6c9e3762b56f1382a6f789a0cd22e32a2fe640ba (patch)
treed475396f857f2540f784170c7d6630604d761af4 /src
parentdbf3435cde74a1300c991ce9e768fa0d235ad52a (diff)
downloadtor-6c9e3762b56f1382a6f789a0cd22e32a2fe640ba.tar.gz
tor-6c9e3762b56f1382a6f789a0cd22e32a2fe640ba.zip
clean up sev_to_string hack in log.c
svn:r355
Diffstat (limited to 'src')
-rw-r--r--src/common/log.c48
1 files changed, 11 insertions, 37 deletions
diff --git a/src/common/log.c b/src/common/log.c
index 12785d8704..75a0643997 100644
--- a/src/common/log.c
+++ b/src/common/log.c
@@ -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);