changeset 11182:6a27203d4439 HEAD

deliver_log_format: Added support for size and vsize
author Timo Sirainen <tss@iki.fi>
date Wed, 21 Apr 2010 19:58:10 +0300
parents b6b81af98381
children b3cfa3dfd5ba
files doc/example-config/conf.d/10-logging.conf src/lib-lda/mail-deliver.c
diffstat 2 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/doc/example-config/conf.d/10-logging.conf	Tue Apr 20 18:26:28 2010 +0300
+++ b/doc/example-config/conf.d/10-logging.conf	Wed Apr 21 19:58:10 2010 +0300
@@ -80,4 +80,6 @@
 #  %m - Message-ID
 #  %s - Subject
 #  %f - From address
+#  %p - Physical size
+#  %w - Virtual size
 #deliver_log_format = msgid=%m: %$
--- a/src/lib-lda/mail-deliver.c	Tue Apr 20 18:26:28 2010 +0300
+++ b/src/lib-lda/mail-deliver.c	Wed Apr 21 19:58:10 2010 +0300
@@ -40,9 +40,12 @@
 		{ 'm', NULL, "msgid" },
 		{ 's', NULL, "subject" },
 		{ 'f', NULL, "from" },
+		{ 'p', NULL, "size" },
+		{ 'w', NULL, "vsize" },
 		{ '\0', NULL, NULL }
 	};
 	struct var_expand_table *tab;
+	uoff_t size;
 	unsigned int i;
 
 	tab = t_malloc(sizeof(static_tab));
@@ -52,6 +55,10 @@
 	(void)mail_get_first_header(ctx->src_mail, "Message-ID", &tab[1].value);
 	(void)mail_get_first_header_utf8(ctx->src_mail, "Subject", &tab[2].value);
 	tab[3].value = mail_deliver_get_address(ctx, "From");
+	if (mail_get_physical_size(ctx->src_mail, &size) == 0)
+		tab[4].value = dec2str(size);
+	if (mail_get_virtual_size(ctx->src_mail, &size) == 0)
+		tab[5].value = dec2str(size);
 	for (i = 1; tab[i].key != '\0'; i++)
 		tab[i].value = str_sanitize(tab[i].value, 80);
 	return tab;