dovecot-2.0: doveadm log find: Find the log more reliably.

dovecot at dovecot.org dovecot at dovecot.org
Wed Jun 16 19:37:09 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/dd1f0a7127a9
changeset: 11556:dd1f0a7127a9
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Jun 16 17:37:00 2010 +0100
description:
doveadm log find: Find the log more reliably.

diffstat:

 src/doveadm/doveadm-log.c |  15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diffs (47 lines):

diff -r 33f9b211f213 -r dd1f0a7127a9 src/doveadm/doveadm-log.c
--- a/src/doveadm/doveadm-log.c	Wed Jun 16 17:02:09 2010 +0100
+++ b/src/doveadm/doveadm-log.c	Wed Jun 16 17:37:00 2010 +0100
@@ -29,8 +29,11 @@
 	for (i = 0; i < LAST_LOG_TYPE; i++) {
 		const char *prefix = failure_log_type_prefixes[i];
 
-		i_log_type(i, TEST_LOG_MSG_PREFIX"%s log",
-			   t_str_lcase(t_strcut(prefix, ':')));
+		/* add timestamp so that syslog won't just write
+		   "repeated message" text */
+		i_log_type(i, TEST_LOG_MSG_PREFIX"%s log (%u)",
+			   t_str_lcase(t_strcut(prefix, ':')),
+			   (unsigned int)ioloop_time);
 	}
 }
 
@@ -102,7 +105,8 @@
 		if (S_ISDIR(st.st_mode)) {
 			/* recursively go through all subdirectories */
 			cmd_log_find_syslog_files(ctx, str_c(full_path));
-		} else {
+		} else if (hash_table_lookup(ctx->files,
+					     str_c(full_path)) == NULL) {
 			file = p_new(ctx->pool, struct log_find_file, 1);
 			file->size = st.st_size;
 			file->path = key =
@@ -138,7 +142,9 @@
 	fd = open(file->path, O_RDONLY);
 	if (fd == -1)
 		return;
+	
 	input = i_stream_create_fd(fd, 1024, TRUE);
+	i_stream_seek(input, file->size);
 	while ((line = i_stream_read_next_line(input)) != NULL) {
 		p = strstr(line, TEST_LOG_MSG_PREFIX);
 		if (p == NULL)
@@ -164,8 +170,7 @@
 	while (hash_table_iterate(iter, &key, &value)) {
 		struct log_find_file *file = value;
 
-		if (file->mask != 0 ||
-		    stat(file->path, &st) < 0 ||
+		if (stat(file->path, &st) < 0 ||
 		    (uoff_t)st.st_size <= file->size)
 			continue;
 


More information about the dovecot-cvs mailing list