summaryrefslogtreecommitdiff
path: root/src/log.c
diff options
context:
space:
mode:
author/C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org </C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org>2008-01-18 13:09:49 +0000
committer/C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org </C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org>2008-01-18 13:09:49 +0000
commit91d431dacd79d93d671ace690e2e9c7fbb0f2877 (patch)
tree40757240f65899615dfc4f6b1f8c7b2f47d4af48 /src/log.c
parent406e9ad8c741fe18b9f3722bed679c3dc4e96614 (diff)
downloadconntrack-tools-91d431dacd79d93d671ace690e2e9c7fbb0f2877.tar.gz
conntrack-tools-91d431dacd79d93d671ace690e2e9c7fbb0f2877.zip
Max Kellermann <max@duempel.org>:
Simplify logging infrastructure
Diffstat (limited to 'src/log.c')
-rw-r--r--src/log.c34
1 files changed, 9 insertions, 25 deletions
diff --git a/src/log.c b/src/log.c
index 41b2057..51e757f 100644
--- a/src/log.c
+++ b/src/log.c
@@ -19,7 +19,6 @@
*/
#include "log.h"
-#include "buffer.h"
#include "conntrackd.h"
#include <time.h>
@@ -38,6 +37,8 @@ int init_log(void)
strerror(errno));
return -1;
}
+
+ setlinebuf(STATE(log));
}
if (CONFIG(stats).logfile[0]) {
@@ -48,6 +49,8 @@ int init_log(void)
strerror(errno));
return -1;
}
+
+ setlinebuf(STATE(stats_log));
}
if (CONFIG(syslog_facility) != -1 ||
@@ -57,8 +60,9 @@ int init_log(void)
return 0;
}
-void dlog(FILE *fd, int priority, const char *format, ...)
+void dlog(int priority, const char *format, ...)
{
+ FILE *fd = STATE(log);
time_t t;
char *buf;
const char *prio;
@@ -100,16 +104,9 @@ void dlog(FILE *fd, int priority, const char *format, ...)
}
}
-void dlog_buffered_ct_flush(void *buffer_data, void *data)
-{
- FILE *fd = data;
-
- fputs((const char*)buffer_data, fd);
- fflush(fd);
-}
-
-void dlog_buffered_ct(FILE *fd, struct buffer *b, struct nf_conntrack *ct)
+void dlog_ct(struct nf_conntrack *ct)
{
+ FILE *fd = STATE(stats_log);
time_t t;
char buf[1024];
char *tmp;
@@ -122,20 +119,7 @@ void dlog_buffered_ct(FILE *fd, struct buffer *b, struct nf_conntrack *ct)
if (fd) {
snprintf(buf+strlen(buf), 1024-strlen(buf), "\n");
- /* zero size buffer: force fflush */
- if (buffer_size(b) == 0) {
- fputs(buf, fd);
- fflush(fd);
- }
-
- if (buffer_add(b, buf, strlen(buf)) == -1) {
- buffer_flush(b, dlog_buffered_ct_flush, fd);
- if (buffer_add(b, buf, strlen(buf)) == -1) {
- /* buffer too small, catacrocket! */
- fputs(buf, fd);
- fflush(fd);
- }
- }
+ fputs(buf, fd);
}
if (CONFIG(stats).syslog_facility != -1)