From 88b091cc95b346da50d21ba2526c76d760ad97fa Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Sat, 10 Feb 2001 05:54:35 +0000 Subject: Write buffer - logs and rawlogs write to files through this. By default everything gets written immediately, but you can make it wait until there's specified amount of data in buffer or write once in a hour or so. Useful for people who want to keep hard disk at sleep at nights but still want to log. /SET write_buffer_mins, /SET write_buffer_kb: When to flush buffer. /FLUSHBUFFER: Flush the buffer immediately git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1201 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/core/rawlog.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/core/rawlog.c') diff --git a/src/core/rawlog.c b/src/core/rawlog.c index d935d1ac..4e47040c 100644 --- a/src/core/rawlog.c +++ b/src/core/rawlog.c @@ -23,7 +23,7 @@ #include "modules.h" #include "signals.h" #include "misc.h" - +#include "write-buffer.h" #include "settings.h" static int rawlog_lines; @@ -45,7 +45,10 @@ void rawlog_destroy(RAWLOG_REC *rawlog) g_slist_foreach(rawlog->lines, (GFunc) g_free, NULL); g_slist_free(rawlog->lines); - if (rawlog->logging) close(rawlog->handle); + if (rawlog->logging) { + write_buffer_flush(); + close(rawlog->handle); + } g_free(rawlog); } @@ -61,8 +64,8 @@ static void rawlog_add(RAWLOG_REC *rawlog, char *str) } if (rawlog->logging) { - write(rawlog->handle, str, strlen(str)); - write(rawlog->handle, "\n", 1); + write_buffer(rawlog->handle, str, strlen(str)); + write_buffer(rawlog->handle, "\n", 1); } rawlog->lines = g_slist_append(rawlog->lines, str); @@ -125,6 +128,7 @@ void rawlog_open(RAWLOG_REC *rawlog, const char *fname) void rawlog_close(RAWLOG_REC *rawlog) { if (rawlog->logging) { + write_buffer_flush(); close(rawlog->handle); rawlog->logging = 0; } -- cgit v1.2.3