[sylpheed:30075] [PATCH] log filtering decisions

Randy Dunlap rdunlap at xenotime.net
Tue Sep 26 10:41:48 JST 2006


FYI, if anyone is interested.  I had some funky filtering
happening and wanted to see why, and this patch helped me.

---

When debug_mode is enabled ("--debug"), log filter decisions via
debug_print() so one can see why certain filtering rules are being applied.

---

 libsylph/filter.c |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+)

diff -Naurp sylpheed-2.2.9/libsylph/filter.c~logit sylpheed-2.2.9/libsylph/filter.c
--- sylpheed-2.2.9/libsylph/filter.c~logit	2006-08-31 01:21:16.000000000 -0700
+++ sylpheed-2.2.9/libsylph/filter.c	2006-09-25 17:11:43.000000000 -0700
@@ -364,6 +364,9 @@ static gboolean filter_match_cond(Filter
 	case FLT_COND_BODY:
 		matched = procmime_find_string(msginfo, cond->str_value,
 					       cond->match_func);
+		if (matched)
+			debug_print("filter-log: match in procmime_find_string (in body): str_value: [%s]\n",
+				cond->str_value);
 		break;
 	case FLT_COND_CMD_TEST:
 		file = procmsg_get_message_file(msginfo);
@@ -371,29 +374,54 @@ static gboolean filter_match_cond(Filter
 		matched = (execute_command_line(cmdline, FALSE) == 0);
 		g_free(cmdline);
 		g_free(file);
+		if (matched)
+			debug_print("filter-log: match in procmsg_get_message_file (in command test): str_value: [%s]\n",
+				cond->str_value);
 		break;
 	case FLT_COND_SIZE_GREATER:
 		matched = (msginfo->size > cond->int_value * 1024);
+		if (matched)
+			debug_print("filter-log: match in (SIZE_GREATER): %d > %d\n",
+				msginfo->size, cond->int_value * 1024);
 		break;
 	case FLT_COND_AGE_GREATER:
 		matched = (time(NULL) - msginfo->date_t >
 				cond->int_value * 24 * 60 * 60);
+		if (matched)
+			debug_print("filter-log: match in (AGE_GREATER): %d > %d\n",
+				time(NULL) - msginfo->date_t,
+				cond->int_value * 24 * 60 * 60);
 		break;
 	case FLT_COND_UNREAD:
 		matched = MSG_IS_UNREAD(msginfo->flags);
+		if (matched)
+			debug_print("filter-log: match in (UNREAD): flags: %d\n",
+				msginfo->flags);
 		break;
 	case FLT_COND_MARK:
 		matched = MSG_IS_MARKED(msginfo->flags);
+		if (matched)
+			debug_print("filter-log: match in (MARKED): flags: %d\n",
+				msginfo->flags);
 		break;
 	case FLT_COND_COLOR_LABEL:
 		matched = (MSG_GET_COLORLABEL_VALUE(msginfo->flags) != 0);
+		if (matched)
+			debug_print("filter-log: match in (COLOR_LABEL): %d\n",
+				msginfo->flags);
 		break;
 	case FLT_COND_MIME:
 		matched = MSG_IS_MIME(msginfo->flags);
+		if (matched)
+			debug_print("filter-log: match in (IS_MIME): %d\n",
+				msginfo->flags);
 		break;
 	case FLT_COND_ACCOUNT:
 		cond_ac = account_find_from_id(cond->int_value);
 		matched = (cond_ac != NULL && cond_ac == fltinfo->account);
+		if (matched)
+			debug_print("filter-log: match in (ACCOUNT): %d\n",
+				cond->int_value);
 		break;
 	default:
 		g_warning("filter_match_cond(): unknown condition: %d\n",
@@ -451,6 +479,9 @@ static gboolean filter_match_header_cond
 	if (FLT_IS_NOT_MATCH(cond->match_flag))
 		matched = !matched;
 
+	if (matched)
+		debug_print("filter-log: match in %s: header_name: [%s], str_value: [%s]\n",
+			__func__, cond->header_name, cond->str_value);
 	return matched;
 }
 


More information about the Sylpheed mailing list