aboutsummaryrefslogtreecommitdiff
path: root/src/common/log.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2003-06-21 19:03:22 +0000
committerNick Mathewson <nickm@torproject.org>2003-06-21 19:03:22 +0000
commitefbcd71b9ba03c7f931b2c66a3e1b91c5f6d3eeb (patch)
tree825ddc8643dd1fabf34cb390b2d49ef7ca07aa88 /src/common/log.c
parent49f082fcee43d23a3f25b92d1c3f1ce4c235cd21 (diff)
downloadtor-efbcd71b9ba03c7f931b2c66a3e1b91c5f6d3eeb.tar
tor-efbcd71b9ba03c7f931b2c66a3e1b91c5f6d3eeb.tar.gz
Remove false warnings from printf checks
svn:r340
Diffstat (limited to 'src/common/log.c')
-rw-r--r--src/common/log.c39
1 files changed, 21 insertions, 18 deletions
diff --git a/src/common/log.c b/src/common/log.c
index 92c0b3781..12785d870 100644
--- a/src/common/log.c
+++ b/src/common/log.c
@@ -42,33 +42,36 @@ size_t sev_to_string(char *buf, int max, int severity) {
return strlen(buf)+1;
}
+static int loglevel = LOG_DEBUG;
+
static void
logv(int severity, const char *funcname, const char *format, va_list ap)
{
- static int loglevel = LOG_DEBUG;
char buf[201];
time_t t;
struct timeval now;
- if (format) {
-
- if (severity > loglevel)
- return;
- if (gettimeofday(&now,NULL) < 0)
- return;
+ assert(format);
+ if (severity > loglevel)
+ return;
+ if (gettimeofday(&now,NULL) < 0)
+ return;
- 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);
- if (funcname)
- printf("%s(): ", funcname);
- vprintf(format,ap);
- printf("\n");
- } else
- loglevel = severity;
+ 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);
+ if (funcname)
+ printf("%s(): ", funcname);
+ vprintf(format,ap);
+ printf("\n");
+}
+void
+log_set_severity(int severity)
+{
+ loglevel = severity;
}
/* Outputs a message to stdout */