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
This commit is contained in:
Timo Sirainen 2001-02-10 05:54:35 +00:00 committed by cras
commit 88b091cc95
6 changed files with 213 additions and 8 deletions

View file

@ -25,6 +25,7 @@
#include "misc.h"
#include "servers.h"
#include "log.h"
#include "write-buffer.h"
#include "lib-config/iconfig.h"
#include "settings.h"
@ -71,8 +72,8 @@ static void log_write_timestamp(int handle, const char *format,
tm = localtime(&stamp);
if (strftime(str, sizeof(str), format, tm) > 0) {
write(handle, str, strlen(str));
if (suffix != NULL) write(handle, suffix, strlen(suffix));
write_buffer(handle, str, strlen(str));
if (suffix != NULL) write_buffer(handle, suffix, strlen(suffix));
}
}
@ -158,6 +159,7 @@ void log_stop_logging(LOG_REC *log)
fcntl(log->handle, F_SETLK, &lock);
#endif
write_buffer_flush();
close(log->handle);
log->handle = -1;
}
@ -214,7 +216,7 @@ void log_write_rec(LOG_REC *log, const char *str)
log->last = now;
log_write_timestamp(log->handle, log_timestamp, str, now);
write(log->handle, "\n", 1);
write_buffer(log->handle, "\n", 1);
signal_emit("log written", 2, log, str);
}