commit 5eeb6c2: [Minor] Allow to log settings id in log format

Vsevolod Stakhov vsevolod at highsecure.ru
Thu Aug 1 17:14:04 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-08-01 17:47:06 +0100
URL: https://github.com/rspamd/rspamd/commit/5eeb6c28676436f5cba8917f94c04e280e6c05a7

[Minor] Allow to log settings id in log format

---
 src/libserver/cfg_file.h |  1 +
 src/libserver/task.c     | 15 +++++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/src/libserver/cfg_file.h b/src/libserver/cfg_file.h
index 39d997754..54427c190 100644
--- a/src/libserver/cfg_file.h
+++ b/src/libserver/cfg_file.h
@@ -255,6 +255,7 @@ enum rspamd_log_format_type {
 	RSPAMD_LOG_DIGEST,
 	RSPAMD_LOG_FILENAME,
 	RSPAMD_LOG_FORCED_ACTION,
+	RSPAMD_LOG_SETTINGS_ID,
 };
 
 enum rspamd_log_format_flags {
diff --git a/src/libserver/task.c b/src/libserver/task.c
index fd14a68f2..e14ce5c5f 100644
--- a/src/libserver/task.c
+++ b/src/libserver/task.c
@@ -1001,6 +1001,11 @@ rspamd_task_log_check_condition (struct rspamd_task *task,
 			ret = TRUE;
 		}
 		break;
+	case RSPAMD_LOG_SETTINGS_ID:
+		if (task->settings_elt) {
+			ret = TRUE;
+		}
+		break;
 	default:
 		ret = TRUE;
 		break;
@@ -1462,6 +1467,16 @@ rspamd_task_log_variable (struct rspamd_task *task,
 			var.len = sizeof (undef) - 1;
 		}
 		break;
+	case RSPAMD_LOG_SETTINGS_ID:
+		if (task->settings_elt) {
+			var.begin = task->settings_elt->name;
+			var.len = strlen (task->settings_elt->name);
+		}
+		else {
+			var.begin = undef;
+			var.len = sizeof (undef) - 1;
+		}
+		break;
 	default:
 		var = rspamd_task_log_metric_res (task, lf);
 		break;


More information about the Commits mailing list