From 82d272799c0c542bddb725c2ea73e85045bb22d7 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Fri, 11 Aug 2000 20:13:49 +0000 Subject: [PATCH] Autologging fixes: Don't log WHOIS replies by default (autolog_level = all -crap). And with /msg nick1,nick2 don't log to file nick1,nick2.log but nick1.log and nick2.log separately. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@585 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/core/log.c | 15 +++++++++++++-- src/fe-common/core/fe-log.c | 17 +++++++++++++---- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/core/log.c b/src/core/log.c index 0069d329..481c6b96 100644 --- a/src/core/log.c +++ b/src/core/log.c @@ -347,13 +347,24 @@ static void sig_printtext_stripped(void *window, void *server, const char *item, gpointer levelp, const char *str) { + char **items, **tmp; int level; g_return_if_fail(str != NULL); level = GPOINTER_TO_INT(levelp); - if (logs != NULL && level != MSGLEVEL_NEVER) - log_file_write(item, level, str, FALSE); + if (logs == NULL || level == MSGLEVEL_NEVER) + return; + + if (item == NULL) + log_file_write(NULL, level, str, FALSE); + else { + /* there can be multiple items separated with comma */ + items = g_strsplit(item, ",", -1); + for (tmp = items; *tmp != NULL; tmp++) + log_file_write(*tmp, level, str, FALSE); + g_strfreev(items); + } } static int sig_rotate_check(void) diff --git a/src/fe-common/core/fe-log.c b/src/fe-common/core/fe-log.c index 24e7065e..2c87d87f 100644 --- a/src/fe-common/core/fe-log.c +++ b/src/fe-common/core/fe-log.c @@ -331,9 +331,12 @@ static void autolog_log(void *server, const char *target) g_free(fname); } -static void sig_printtext_stripped(WINDOW_REC *window, void *server, const char *target, gpointer levelp, const char *text) +static void sig_printtext_stripped(WINDOW_REC *window, void *server, + const char *target, gpointer levelp, + const char *text) { char windownum[MAX_INT_STRLEN]; + char **targets, **tmp; LOG_REC *log; int level; @@ -341,8 +344,14 @@ static void sig_printtext_stripped(WINDOW_REC *window, void *server, const char if (level == MSGLEVEL_NEVER) return; /* let autolog create the log records */ - if ((autolog_level & level) && target != NULL && *target != '\0') - autolog_log(server, target); + if ((autolog_level & level) && target != NULL && *target != '\0') { + /* there can be multiple targets separated with comma */ + targets = g_strsplit(target, ",", -1); + for (tmp = targets; *tmp != NULL; tmp++) { + autolog_log(server, *tmp); + } + g_strfreev(targets); + } /* save to log created with /WINDOW LOG */ ltoa(windownum, window->refnum); @@ -438,7 +447,7 @@ void fe_log_init(void) autoremove_tag = g_timeout_add(60000, (GSourceFunc) sig_autoremove, NULL); settings_add_str("log", "autolog_path", "~/irclogs/$tag/$0.log"); - settings_add_str("log", "autolog_level", "all"); + settings_add_str("log", "autolog_level", "all -crap"); settings_add_bool("log", "autolog", FALSE); autolog_level = 0;