summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2001-02-17 12:08:31 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2001-02-17 12:08:31 +0000
commite5f12167977baaa520e886395986264443184620 (patch)
tree01378b2670cddb5e209edaad15b54d1d6cdeaf06 /src
parentc0726196eab7e88da3a0138321e7ed02717792de (diff)
downloadirssi-e5f12167977baaa520e886395986264443184620.zip
log_write_rec(): added level parameter. writing /LASTLOG to log files
doesn't anymore print the current timestamp at the start of line since /LASTLOG messages have their original timestamp already. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1235 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src')
-rw-r--r--src/core/log.c29
-rw-r--r--src/core/log.h2
-rw-r--r--src/fe-common/core/fe-log.c2
3 files changed, 18 insertions, 15 deletions
diff --git a/src/core/log.c b/src/core/log.c
index 53951828..e61a537f 100644
--- a/src/core/log.c
+++ b/src/core/log.c
@@ -62,7 +62,7 @@ static int log_item_str2type(const char *type)
}
static void log_write_timestamp(int handle, const char *format,
- const char *suffix, time_t stamp)
+ const char *text, time_t stamp)
{
struct tm *tm;
char str[256];
@@ -71,10 +71,9 @@ static void log_write_timestamp(int handle, const char *format,
if (*format == '\0') return;
tm = localtime(&stamp);
- if (strftime(str, sizeof(str), format, tm) > 0) {
+ if (strftime(str, sizeof(str), format, tm) > 0)
write_buffer(handle, str, strlen(str));
- if (suffix != NULL) write_buffer(handle, suffix, strlen(suffix));
- }
+ if (text != NULL) write_buffer(handle, text, strlen(text));
}
static char *log_filename(LOG_REC *log)
@@ -182,7 +181,7 @@ static void log_rotate_check(LOG_REC *log)
g_free(new_fname);
}
-void log_write_rec(LOG_REC *log, const char *str)
+void log_write_rec(LOG_REC *log, const char *str, int level)
{
struct tm *tm;
time_t now;
@@ -215,7 +214,10 @@ void log_write_rec(LOG_REC *log, const char *str)
log->last = now;
- log_write_timestamp(log->handle, log_timestamp, str, now);
+ if ((level & MSGLEVEL_LASTLOG) == 0)
+ log_write_timestamp(log->handle, log_timestamp, str, now);
+ else
+ write_buffer(log->handle, str, strlen(str));
write_buffer(log->handle, "\n", 1);
signal_emit("log written", 2, log, str);
@@ -268,18 +270,19 @@ void log_file_write(SERVER_REC *server, const char *item, int level,
fallbacks = g_slist_append(fallbacks, rec);
else if (item != NULL && log_item_find(rec, LOG_ITEM_TARGET,
item, server) != NULL)
- log_write_rec(rec, str);
+ log_write_rec(rec, str, level);
}
if (!found && !no_fallbacks && fallbacks != NULL) {
/* not found from any items, so write it to all main logs */
- tmpstr = NULL;
- if (level & MSGLEVEL_PUBLIC)
- tmpstr = g_strconcat(item, ": ", str, NULL);
+ tmpstr = (level & MSGLEVEL_PUBLIC) ?
+ g_strconcat(item, ": ", str, NULL) :
+ g_strdup(str);
+
+ for (tmp = fallbacks; tmp != NULL; tmp = tmp->next)
+ log_write_rec(tmp->data, tmpstr, level);
- g_slist_foreach(fallbacks, (GFunc) log_write_rec,
- tmpstr ? tmpstr : (char *)str);
- g_free_not_null(tmpstr);
+ g_free(tmpstr);
}
g_slist_free(fallbacks);
}
diff --git a/src/core/log.h b/src/core/log.h
index 2fd97a1c..bc4d6036 100644
--- a/src/core/log.h
+++ b/src/core/log.h
@@ -45,7 +45,7 @@ LOG_ITEM_REC *log_item_find(LOG_REC *log, int type, const char *item,
void log_file_write(SERVER_REC *server, const char *item, int level,
const char *str, int no_fallbacks);
-void log_write_rec(LOG_REC *log, const char *str);
+void log_write_rec(LOG_REC *log, const char *str, int level);
int log_start_logging(LOG_REC *log);
void log_stop_logging(LOG_REC *log);
diff --git a/src/fe-common/core/fe-log.c b/src/fe-common/core/fe-log.c
index 25015926..a0ea9760 100644
--- a/src/fe-common/core/fe-log.c
+++ b/src/fe-common/core/fe-log.c
@@ -397,7 +397,7 @@ static void log_single_line(WINDOW_REC *window, void *server,
ltoa(windownum, window->refnum);
log = logs_find_item(LOG_ITEM_WINDOW_REFNUM,
windownum, NULL, NULL);
- if (log != NULL) log_write_rec(log, text);
+ if (log != NULL) log_write_rec(log, text, level);
if (target == NULL)
log_file_write(server, NULL, level, text, FALSE);