diff options
author | Timo Sirainen <cras@irssi.org> | 2001-02-10 05:54:35 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2001-02-10 05:54:35 +0000 |
commit | 88b091cc95b346da50d21ba2526c76d760ad97fa (patch) | |
tree | 399450424a0cef5abf985fd4d271edd557a448a8 /src/core/rawlog.c | |
parent | 5061783f4ce035b2c432fa1b3a45f9213989a45a (diff) | |
download | irssi-88b091cc95b346da50d21ba2526c76d760ad97fa.zip |
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
Diffstat (limited to 'src/core/rawlog.c')
-rw-r--r-- | src/core/rawlog.c | 12 |
1 files changed, 8 insertions, 4 deletions
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; } |