diff --git a/src/lib-sieve/cmd-discard.c b/src/lib-sieve/cmd-discard.c
index 2ebad6bb66d869bebea4db76ac2b1da887e54f0b..108efe4d31f658e5acbeeec71383f0ea815145d5 100644
--- a/src/lib-sieve/cmd-discard.c
+++ b/src/lib-sieve/cmd-discard.c
@@ -133,7 +133,7 @@ static bool act_discard_commit
 	const struct sieve_action_exec_env *aenv, 
 	void *tr_context ATTR_UNUSED, bool *keep)
 {
-	sieve_result_log(aenv, 
+	sieve_result_global_log(aenv, 
 		"marked message to be discarded if not explicitly delivered "
 		"(discard action)");
 	*keep = FALSE;
diff --git a/src/lib-sieve/cmd-redirect.c b/src/lib-sieve/cmd-redirect.c
index f682d9818b3e8941624d5bad11638303400c3e1f..c848f8236bb09c566c3bd86d039281563857b428 100644
--- a/src/lib-sieve/cmd-redirect.c
+++ b/src/lib-sieve/cmd-redirect.c
@@ -308,7 +308,8 @@ static bool act_redirect_send
 	
 	/* Just to be sure */
 	if ( !sieve_smtp_available(senv) ) {
-		sieve_result_warning(aenv, "redirect action has no means to send mail.");
+		sieve_result_global_warning
+			(aenv, "redirect action has no means to send mail.");
 		return TRUE;
 	}
 	
@@ -341,7 +342,7 @@ static bool act_redirect_send
 
 	/* Close SMTP transport */
 	if ( !sieve_smtp_close(senv, smtp_handle) ) {
-		sieve_result_error(aenv, 
+		sieve_result_global_error(aenv, 
 			"failed to redirect message to <%s> "
 			"(refer to server log for more information)",
 			str_sanitize(ctx->to_address, 80));
@@ -368,7 +369,7 @@ static bool act_redirect_commit
 	if (dupeid != NULL) {
 		/* Check whether we've seen this message before */
 		if (sieve_action_duplicate_check(senv, dupeid, strlen(dupeid))) {
-			sieve_result_log(aenv, "discarded duplicate forward to <%s>",
+			sieve_result_global_log(aenv, "discarded duplicate forward to <%s>",
 				str_sanitize(ctx->to_address, 128));
 			return TRUE;
 		}
@@ -383,7 +384,7 @@ static bool act_redirect_commit
 				ioloop_time + CMD_REDIRECT_DUPLICATE_KEEP);
 		}
 
-		sieve_result_log(aenv, "forwarded to <%s>", 
+		sieve_result_global_log(aenv, "forwarded to <%s>", 
 			str_sanitize(ctx->to_address, 128));	
 
 		/* Indicate that message was successfully forwarded */
diff --git a/src/lib-sieve/ext-reject.c b/src/lib-sieve/ext-reject.c
index 7be0367332db88029e5fed80800c00b86a183fbb..e942b852340ba15bb1dae3baccc977cbf5c878d6 100644
--- a/src/lib-sieve/ext-reject.c
+++ b/src/lib-sieve/ext-reject.c
@@ -403,7 +403,8 @@ static bool act_reject_send
 
 	/* Just to be sure */
 	if ( !sieve_smtp_available(senv) ) {
-		sieve_result_warning(aenv, "reject action has no means to send mail");
+		sieve_result_global_warning
+			(aenv, "reject action has no means to send mail");
 		return TRUE;
 	}
 
@@ -485,7 +486,7 @@ static bool act_reject_send
 	fprintf(f, "\r\n\r\n--%s--\r\n", boundary);
 
 	if ( !sieve_smtp_close(senv, smtp_handle) ) {
-		sieve_result_error(aenv,
+		sieve_result_global_error(aenv,
 			"failed to send rejection message to <%s> "
 			"(refer to server log for more information)",
 			str_sanitize(sender, 80));
@@ -505,13 +506,13 @@ static bool act_reject_commit
 	const char *recipient = sieve_message_get_recipient(aenv->msgctx);
 
 	if ( recipient == NULL ) {
-		sieve_result_warning(aenv, 
+		sieve_result_global_warning(aenv, 
 			"reject action aborted: envelope recipient is <>");
 		return TRUE;
 	}
 	
 	if ( rj_ctx->reason == NULL ) {
-		sieve_result_log(aenv, 
+		sieve_result_global_log(aenv, 
 			"not sending reject message (would cause second response to sender)");
     
 		*keep = FALSE;
@@ -519,14 +520,14 @@ static bool act_reject_commit
 	}
 
 	if ( sender == NULL ) {
-		sieve_result_log(aenv, "not sending reject message to <>");
+		sieve_result_global_log(aenv, "not sending reject message to <>");
     
 		*keep = FALSE;
 		return TRUE;
 	}
 		
 	if ( act_reject_send(aenv, rj_ctx, sender, recipient) ) {
-		sieve_result_log(aenv, 
+		sieve_result_global_log(aenv, 
 			"rejected message from <%s> (%s)", str_sanitize(sender, 80),
 			( rj_ctx->ereject ? "ereject" : "reject" ));
 
diff --git a/src/lib-sieve/plugins/enotify/cmd-notify.c b/src/lib-sieve/plugins/enotify/cmd-notify.c
index 15f924c8454d3b5ed37ae655820f7e32f3ebb6ba..ccba652303c00d426a1cb85289656f8d047df009 100644
--- a/src/lib-sieve/plugins/enotify/cmd-notify.c
+++ b/src/lib-sieve/plugins/enotify/cmd-notify.c
@@ -502,9 +502,8 @@ static int cmd_notify_operation_execute
 /* Runtime verification */
 
 static int act_notify_check_duplicate
-(const struct sieve_runtime_env *renv ATTR_UNUSED, 
-	const struct sieve_action *act ATTR_UNUSED,
-	const struct sieve_action *act_other ATTR_UNUSED)
+(const struct sieve_runtime_env *renv, const struct sieve_action *act,
+	const struct sieve_action *act_other)
 {
 	const struct sieve_enotify_action *nact, *nact_other;
 	const struct sieve_enotify_method_def *nmth_def;
@@ -525,6 +524,7 @@ static int act_notify_check_duplicate
 		return 0;
 
 	memset(&nenv, 0, sizeof(nenv));
+	nenv.svinst = renv->svinst;
 	nenv.method = nact->method;	
 	nenv.ehandler = sieve_prefix_ehandler_create
 		(sieve_result_get_error_handler(renv->result), act->location, "notify");
@@ -578,6 +578,7 @@ static bool act_notify_commit
 	if ( method->def != NULL && method->def->action_execute != NULL )	{	
 		/* Compose log structure */
 		memset(&nenv, 0, sizeof(nenv));
+		nenv.svinst = aenv->svinst;
 		nenv.method = method;	
 		nenv.scriptenv = aenv->scriptenv;
 		nenv.msgdata = aenv->msgdata;
diff --git a/src/lib-sieve/plugins/enotify/ext-enotify-common.c b/src/lib-sieve/plugins/enotify/ext-enotify-common.c
index c4c420e31fd6a364b019b1c1bb6f73577f95916a..1a53f6ce0112cf74694588a5400eafa3b7b25e3b 100644
--- a/src/lib-sieve/plugins/enotify/ext-enotify-common.c
+++ b/src/lib-sieve/plugins/enotify/ext-enotify-common.c
@@ -305,6 +305,7 @@ static bool ext_enotify_option_parse
 } 
 
 struct _ext_enotify_option_check_context {
+	struct sieve_instance *svinst;
 	struct sieve_validator *valdtr;
 	const struct sieve_enotify_method *method;
 };
@@ -323,6 +324,7 @@ static int _ext_enotify_option_check
 	
 	/* Compose log structure */
 	memset(&nenv, 0, sizeof(nenv));
+	nenv.svinst = optn_context->svinst;
 	nenv.method = method;	
 	nenv.ehandler = sieve_prefix_ehandler_create
 		(sieve_validator_error_handler(valdtr), 
@@ -366,6 +368,7 @@ bool ext_enotify_compile_check_arguments
 	struct sieve_ast_argument *from_arg, struct sieve_ast_argument *options_arg)
 {
 	const struct sieve_extension *this_ext = cmd->ext;
+	struct sieve_instance *svinst = this_ext->svinst;
 	const char *uri = sieve_ast_argument_strc(uri_arg);
 	const char *scheme;
 	const struct sieve_enotify_method *method;
@@ -397,6 +400,7 @@ bool ext_enotify_compile_check_arguments
 
 	/* Compose log structure */
 	memset(&nenv, 0, sizeof(nenv));
+	nenv.svinst = svinst;
 	nenv.method = method;	
 	
 	/* Check URI itself */
@@ -450,7 +454,8 @@ bool ext_enotify_compile_check_arguments
 	/* Check :options argument */
 	if ( result && options_arg != NULL ) {
 		struct sieve_ast_argument *option = options_arg;
-		struct _ext_enotify_option_check_context optn_context = { valdtr, method };
+		struct _ext_enotify_option_check_context optn_context = 
+			{ svinst, valdtr, method };
 		
 		/* Parse and check options */
 		result = ( sieve_ast_stringlist_map
@@ -494,6 +499,7 @@ bool ext_enotify_runtime_method_validate
 		struct sieve_enotify_env nenv;
 
 		memset(&nenv, 0, sizeof(nenv));
+		nenv.svinst = renv->svinst;
 		nenv.method = method;
 		nenv.ehandler = sieve_prefix_ehandler_create
 			(sieve_interpreter_get_error_handler(renv->interp),
@@ -558,6 +564,7 @@ const char *ext_enotify_runtime_get_method_capability
 		struct sieve_enotify_env nenv; 
 
 		memset(&nenv, 0, sizeof(nenv));
+		nenv.svinst = renv->svinst;
 		nenv.method = method;
 		nenv.ehandler = sieve_prefix_ehandler_create
 			(sieve_interpreter_get_error_handler(renv->interp),
@@ -592,6 +599,7 @@ int ext_enotify_runtime_check_operands
 		int result = SIEVE_EXEC_OK;
 
 		memset(&nenv, 0, sizeof(nenv));
+		nenv.svinst = renv->svinst;
 		nenv.method = method;
 		nenv.ehandler = sieve_prefix_ehandler_create
 			(sieve_interpreter_get_error_handler(renv->interp),
diff --git a/src/lib-sieve/plugins/enotify/mailto/ntfy-mailto.c b/src/lib-sieve/plugins/enotify/mailto/ntfy-mailto.c
index 3083d0eb63e4f6dab92a60090e9f4962691c2063..5e4dd4992c297b6a967da05d0e13565bf1296c55 100644
--- a/src/lib-sieve/plugins/enotify/mailto/ntfy-mailto.c
+++ b/src/lib-sieve/plugins/enotify/mailto/ntfy-mailto.c
@@ -401,7 +401,7 @@ static bool ntfy_mailto_send
 
 	/* Just to be sure */
 	if ( !sieve_smtp_available(senv) ) {
-		sieve_enotify_warning(nenv, 
+		sieve_enotify_global_warning(nenv, 
 			"notify mailto method has no means to send mail");
 		return TRUE;
 	}
@@ -531,11 +531,11 @@ static bool ntfy_mailto_send
 		}
 	
 		if ( sieve_smtp_close(senv, smtp_handle) ) {
-			sieve_enotify_info(nenv, 
+			sieve_enotify_global_info(nenv, 
 				"sent mail notification to <%s>", 
 				str_sanitize(recipients[i].normalized, 80));
 		} else {
-			sieve_enotify_error(nenv,
+			sieve_enotify_global_error(nenv,
 				"failed to send mail notification to <%s> "
 				"(refer to system log for more information)", 
 				str_sanitize(recipients[i].normalized, 80));
@@ -556,7 +556,7 @@ static bool ntfy_mailto_action_execute
 	/* Is the recipient unset? 
 	 */
 	if ( recipient == NULL ) {
-		sieve_enotify_warning(nenv, 
+		sieve_enotify_global_warning(nenv, 
 			"notify mailto action aborted: envelope recipient is <>");
 		return TRUE;
 	}
@@ -569,7 +569,7 @@ static bool ntfy_mailto_action_execute
 		/* Theoretically multiple headers could exist, so lets make sure */
 		while ( *hdsp != NULL ) {
 			if ( strcasecmp(*hdsp, "no") != 0 ) {
-				sieve_enotify_info(nenv, 
+				sieve_enotify_global_info(nenv, 
 					"not sending notification for auto-submitted message from <%s>", 
 					str_sanitize(sender, 128));	
 					return TRUE;				 
diff --git a/src/lib-sieve/plugins/enotify/sieve-ext-enotify.h b/src/lib-sieve/plugins/enotify/sieve-ext-enotify.h
index a87edd3523d002c857ee537b5054ae74d0c5afb5..28bf9e2d593f02446471d2a555f1d12c6de19bfd 100644
--- a/src/lib-sieve/plugins/enotify/sieve-ext-enotify.h
+++ b/src/lib-sieve/plugins/enotify/sieve-ext-enotify.h
@@ -101,6 +101,8 @@ void  sieve_enotify_method_unregister
  */
 
 struct sieve_enotify_env {
+	struct sieve_instance *svinst;
+
 	const struct sieve_enotify_method *method;
 
 	struct sieve_error_handler *ehandler;
@@ -119,6 +121,8 @@ void sieve_enotify_method_printf
  */
 
 struct sieve_enotify_exec_env {
+	struct sieve_instance *svinst;
+	
 	const struct sieve_enotify_method *method;
 
 	const struct sieve_script_env *scriptenv;
@@ -154,6 +158,14 @@ struct sieve_enotify_action {
 #define sieve_enotify_info(ENV, ...) \
 	sieve_info((ENV)->ehandler, NULL, __VA_ARGS__ )
 
+#define sieve_enotify_global_error(ENV, ...) \
+	sieve_global_error((ENV)->svinst, (ENV)->ehandler, NULL, __VA_ARGS__ )
+	
+#define sieve_enotify_global_warning(ENV, ...) \
+	sieve_global_warning((ENV)->svinst, (ENV)->ehandler, NULL, __VA_ARGS__ )
+
+#define sieve_enotify_global_info(ENV, ...) \
+	sieve_global_info((ENV)->svinst, (ENV)->ehandler, NULL, __VA_ARGS__ )
 
 #endif /* __SIEVE_EXT_ENOTIFY_H */
 
diff --git a/src/lib-sieve/plugins/notify/cmd-notify.c b/src/lib-sieve/plugins/notify/cmd-notify.c
index 773cbbdd010739b3def02afae09f03d89b50c5cf..05c9321e4a444c7a1f1fef4d0d56a92d814e8705 100644
--- a/src/lib-sieve/plugins/notify/cmd-notify.c
+++ b/src/lib-sieve/plugins/notify/cmd-notify.c
@@ -703,7 +703,7 @@ static bool act_notify_send
 
 	/* Just to be sure */
 	if ( senv->smtp_open == NULL || senv->smtp_close == NULL ) {
-		sieve_result_warning(aenv, 
+		sieve_result_global_warning(aenv, 
 			"notify action has no means to send mail");
 		return TRUE;
 	}
@@ -763,11 +763,11 @@ static bool act_notify_send
 		fprintf(f, "%s\r\n", act->message);
 			
 		if ( sieve_smtp_close(senv, smtp_handle) ) {
-			sieve_result_log(aenv, 
+			sieve_result_global_log(aenv, 
 				"sent mail notification to <%s>", 
 				str_sanitize(recipients[i].normalized, 80));
 		} else {
-			sieve_result_error(aenv,
+			sieve_result_global_error(aenv,
 				"failed to send mail notification to <%s> "
 				"(refer to system log for more information)", 
 				str_sanitize(recipients[i].normalized, 80));
@@ -794,7 +794,7 @@ static bool act_notify_commit
 		/* Theoretically multiple headers could exist, so lets make sure */
 		while ( *hdsp != NULL ) {
 			if ( strcasecmp(*hdsp, "no") != 0 ) {
-				sieve_result_log(aenv, 
+				sieve_result_global_log(aenv, 
 					"not sending notification for auto-submitted message from <%s>", 
 					str_sanitize(msgdata->return_path, 128));	
 					return TRUE;				 
diff --git a/src/lib-sieve/plugins/vacation/cmd-vacation.c b/src/lib-sieve/plugins/vacation/cmd-vacation.c
index 5d057fef9a837e6cf904bd8de3ba10b328be04c4..bbabae3daacc79355aea3c7f776eadf085574e89 100644
--- a/src/lib-sieve/plugins/vacation/cmd-vacation.c
+++ b/src/lib-sieve/plugins/vacation/cmd-vacation.c
@@ -858,7 +858,8 @@ static bool act_vacation_send
 	/* Check smpt functions just to be sure */
 
 	if ( !sieve_smtp_available(senv) ) {
-		sieve_result_warning(aenv, "vacation action has no means to send mail");
+		sieve_result_global_warning(aenv,
+			"vacation action has no means to send mail");
 		return TRUE;
 	}
 
@@ -937,7 +938,7 @@ static bool act_vacation_send
 
 	/* Close smtp session */    
 	if ( !sieve_smtp_close(senv, smtp_handle) ) {
-		sieve_result_error(aenv, 
+		sieve_result_global_error(aenv, 
 			"failed to send vacation response to <%s> "
 			"(refer to server log for more information)", 
 			str_sanitize(reply_to, 128));	
@@ -979,14 +980,15 @@ static bool act_vacation_commit
 	/* Is the recipient unset? 
 	 */
 	if ( recipient == NULL ) {
-		sieve_result_warning(aenv, "vacation action aborted: envelope recipient is <>");
+		sieve_result_global_warning
+			(aenv, "vacation action aborted: envelope recipient is <>");
 		return TRUE;
 	}
 
 	/* Is the return path unset ?
 	 */
 	if ( sender == NULL ) {
-		sieve_result_log(aenv, "discarded vacation reply to <>");
+		sieve_result_global_log(aenv, "discarded vacation reply to <>");
 		return TRUE;
 	}    
 	
@@ -995,7 +997,7 @@ static bool act_vacation_commit
 	 */
 	if ( sieve_address_compare(sender, recipient, TRUE) 
 		== 0 ) {
-		sieve_result_log(aenv, "discarded vacation reply to own address");	
+		sieve_result_global_log(aenv, "discarded vacation reply to own address");	
 		return TRUE;
 	}
 	
@@ -1005,7 +1007,8 @@ static bool act_vacation_commit
 	
 		if ( sieve_action_duplicate_check(senv, dupl_hash, sizeof(dupl_hash)) ) 
 		{
-			sieve_result_log(aenv, "discarded duplicate vacation response to <%s>",
+			sieve_result_global_log(aenv,
+				"discarded duplicate vacation response to <%s>",
 				str_sanitize(sender, 128));
 			return TRUE;
 		}
@@ -1017,7 +1020,7 @@ static bool act_vacation_commit
 		if ( mail_get_headers
 			(msgdata->mail, *hdsp, &headers) >= 0 && headers[0] != NULL ) {	
 			/* Yes, bail out */
-			sieve_result_log(aenv, 
+			sieve_result_global_log(aenv, 
 				"discarding vacation response to mailinglist recipient <%s>", 
 				str_sanitize(sender, 128));	
 			return TRUE;				 
@@ -1032,7 +1035,7 @@ static bool act_vacation_commit
 		hdsp = headers;
 		while ( *hdsp != NULL ) {
 			if ( strcasecmp(*hdsp, "no") != 0 ) {
-				sieve_result_log(aenv, 
+				sieve_result_global_log(aenv, 
 					"discarding vacation response to auto-submitted message from <%s>", 
 					str_sanitize(sender, 128));	
 					return TRUE;				 
@@ -1049,7 +1052,7 @@ static bool act_vacation_commit
 		while ( *hdsp != NULL ) {
 			if ( strcasecmp(*hdsp, "junk") == 0 || strcasecmp(*hdsp, "bulk") == 0 ||
 				strcasecmp(*hdsp, "list") == 0 ) {
-				sieve_result_log(aenv, 
+				sieve_result_global_log(aenv, 
 					"discarding vacation response to precedence=%s message from <%s>", 
 					*hdsp, str_sanitize(sender, 128));	
 					return TRUE;				 
@@ -1060,7 +1063,7 @@ static bool act_vacation_commit
 	
 	/* Do not reply to system addresses */
 	if ( _is_system_address(sender) ) {
-		sieve_result_log(aenv, 
+		sieve_result_global_log(aenv, 
 			"not sending vacation response to system address <%s>", 
 			str_sanitize(sender, 128));	
 		return TRUE;				
@@ -1097,7 +1100,7 @@ static bool act_vacation_commit
 
 	if ( *hdsp == NULL ) {
 		/* No, bail out */
-		sieve_result_log(aenv, 
+		sieve_result_global_log(aenv, 
 			"discarding vacation response for message implicitly delivered to <%s>",
 			recipient );	
 		return TRUE;				 
@@ -1106,7 +1109,7 @@ static bool act_vacation_commit
 	/* Send the message */
 	
 	if ( act_vacation_send(aenv, ctx, sender, reply_from) ) {
-		sieve_result_log(aenv, "sent vacation response to <%s>", 
+		sieve_result_global_log(aenv, "sent vacation response to <%s>", 
 			str_sanitize(sender, 128));	
 
 		/* Mark as replied */
diff --git a/src/lib-sieve/sieve-actions.c b/src/lib-sieve/sieve-actions.c
index 3d34576c68052f37ad6b30244d707abf7a425879..49597afaa981dbb3e620412435bf76bf16b0d508 100644
--- a/src/lib-sieve/sieve-actions.c
+++ b/src/lib-sieve/sieve-actions.c
@@ -554,11 +554,13 @@ static void act_store_log_status
 
 	/* Store disabled? */
 	if ( trans->disabled ) {
-		sieve_result_log(aenv, "store into mailbox %s skipped", mailbox_name);
+		sieve_result_global_log
+			(aenv, "store into mailbox %s skipped", mailbox_name);
 
 	/* Store redundant? */
 	} else if ( trans->redundant ) {
-		sieve_result_log(aenv, "left message in mailbox %s", mailbox_name);
+		sieve_result_global_log
+			(aenv, "left message in mailbox %s", mailbox_name);
 
 	/* Store failed? */
 	} else if ( !status ) {
@@ -573,22 +575,24 @@ static void act_store_log_status
 				(mailbox_get_storage(trans->box), &error_code);
 		}
 
-		if ( error_code != MAIL_ERROR_NOTFOUND || error_code != MAIL_ERROR_PARAMS ) {
-			sieve_result_error(aenv, "failed to store into mailbox %s: %s",
+		if ( error_code != MAIL_ERROR_NOTFOUND && error_code != MAIL_ERROR_PARAMS ) 
+			{
+			sieve_result_global_error(aenv, "failed to store into mailbox %s: %s",
 				mailbox_name, errstr);
 		} else {
-			sieve_result_user_error(aenv, "failed to store into mailbox %s: %s",
+			sieve_result_error(aenv, "failed to store into mailbox %s: %s",
 				mailbox_name, errstr);
 		}
 
 	/* Store aborted? */
 	} else if ( rolled_back ) {
-		sieve_result_log(aenv, "store into mailbox %s aborted", mailbox_name);
+		sieve_result_global_log
+			(aenv, "store into mailbox %s aborted", mailbox_name);
 
 	/* Succeeded */
 	} else {
-		sieve_result_log(aenv, "stored mail into mailbox %s", mailbox_name);
-
+		sieve_result_global_log
+			(aenv, "stored mail into mailbox %s", mailbox_name);
 	}
 }
 
diff --git a/src/lib-sieve/sieve-actions.h b/src/lib-sieve/sieve-actions.h
index 974fce8cf33940dd63aa4ba67e474bf773ae2407..51b75da11070cfe6a0051efbb5a268436997fa6d 100644
--- a/src/lib-sieve/sieve-actions.h
+++ b/src/lib-sieve/sieve-actions.h
@@ -16,6 +16,8 @@
  */
 
 struct sieve_action_exec_env { 
+	struct sieve_instance *svinst;
+
 	struct sieve_result *result;
 	struct sieve_error_handler *ehandler;
 
diff --git a/src/lib-sieve/sieve-error-private.h b/src/lib-sieve/sieve-error-private.h
index d4f844b121df107d86415dc973a61e560979facd..1ecf2b7e7f75ce7da24eeed781daf99b77341da3 100644
--- a/src/lib-sieve/sieve-error-private.h
+++ b/src/lib-sieve/sieve-error-private.h
@@ -6,6 +6,14 @@
 
 #include "sieve-error.h"
 
+/*
+ * Types
+ */
+
+enum sieve_error_flags { 
+	SIEVE_ERROR_FLAG_GLOBAL = (1 << 0)
+};
+
 /*
  * Initialization
  */
@@ -30,19 +38,24 @@ struct sieve_error_handler {
 	unsigned int errors;
 	unsigned int warnings;
 
-	/* Should we copy log to i_error, i_warning, i_info and i_debug? */
-	bool log_master;
-
 	/* Should the errorhandler handle or discard info/debug log?
 	 * (This does not influence the previous setting)
 	 */
 	bool log_info;
 	bool log_debug;
 
-	sieve_error_vfunc_t verror;
-	sieve_error_vfunc_t vwarning;
-	sieve_error_vfunc_t vinfo;
-	sieve_error_vfunc_t vdebug;
+	void (*verror)
+		(struct sieve_error_handler *ehandler, unsigned int flags,
+			const char *location, const char *fmt, va_list args);
+	void (*vwarning)
+		(struct sieve_error_handler *ehandler, unsigned int flags,
+			const char *location, const char *fmt, va_list args);
+	void (*vinfo)
+		(struct sieve_error_handler *ehandler, unsigned int flags,
+			const char *location, const char *fmt, va_list args);
+	void (*vdebug)
+		(struct sieve_error_handler *ehandler, unsigned int flags,
+			const char *location, const char *fmt, va_list args);
 
 	void (*free)
 		(struct sieve_error_handler *ehandler);
@@ -60,94 +73,63 @@ void sieve_error_handler_init_from_parent
  * Direct handler calls
  */
 
-static inline void sieve_direct_verror
-(struct sieve_error_handler *ehandler, const char *location, 
-	const char *fmt, va_list args)
-{
-	if ( ehandler->parent != NULL || sieve_errors_more_allowed(ehandler) ) {
-		if ( ehandler->verror != NULL )
-			ehandler->verror(ehandler, location, fmt, args);
-		
-		if ( ehandler->pool != NULL )
-			ehandler->errors++;
-	}
-}
-
-static inline void sieve_direct_vwarning
-(struct sieve_error_handler *ehandler, const char *location, 
-	const char *fmt, va_list args)
-{
-	if ( ehandler->vwarning != NULL )	
-		ehandler->vwarning(ehandler, location, fmt, args);
-
-	if ( ehandler->pool != NULL )
-		ehandler->warnings++;
-}
-
-static inline void sieve_direct_vinfo
-(struct sieve_error_handler *ehandler, const char *location, 
-	const char *fmt, va_list args)
-{
-	if ( ehandler->parent != NULL || ehandler->log_info ) {
-		if ( ehandler->vinfo != NULL )	
-			ehandler->vinfo(ehandler, location, fmt, args);
-	}
-}
-
-static inline void sieve_direct_vdebug
-(struct sieve_error_handler *ehandler, const char *location, 
-	const char *fmt, va_list args)
-{
-	if ( ehandler->parent != NULL || ehandler->log_info ) {
-		if ( ehandler->vdebug != NULL )	
-			ehandler->vdebug(ehandler, location, fmt, args);
-	}
-}
+void sieve_direct_verror
+	(struct sieve_instance *svinst, struct sieve_error_handler *ehandler,
+		unsigned int flags, const char *location, const char *fmt, va_list args);
+void sieve_direct_vwarning
+	(struct sieve_instance *svinst, struct sieve_error_handler *ehandler,
+		unsigned int flags, const char *location, const char *fmt, va_list args);
+void sieve_direct_vinfo
+	(struct sieve_instance *svinst, struct sieve_error_handler *ehandler,
+		unsigned int flags, const char *location, const char *fmt, va_list args);
+void sieve_direct_vdebug
+	(struct sieve_instance *svinst, struct sieve_error_handler *ehandler,
+		unsigned int flags, const char *location, const char *fmt, va_list args);
 
 static inline void sieve_direct_error
-(struct sieve_error_handler *ehandler, const char *location, 
-	const char *fmt, ...)
+(struct sieve_instance *svinst, struct sieve_error_handler *ehandler,
+	unsigned int flags, const char *location, const char *fmt, ...)
 {
 	va_list args;
 	va_start(args, fmt);
 	
-	sieve_direct_verror(ehandler, location, fmt, args);
+	sieve_direct_verror(svinst, ehandler, flags, location, fmt, args);
 	
 	va_end(args);
 }
 
 static inline void sieve_direct_warning
-(struct sieve_error_handler *ehandler, const char *location, 
-	const char *fmt, ...)
+(struct sieve_instance *svinst, struct sieve_error_handler *ehandler,
+	unsigned int flags, const char *location, const char *fmt, ...)
 {
 	va_list args;
 	va_start(args, fmt);
 	
-	sieve_direct_vwarning(ehandler, location, fmt, args);
+	sieve_direct_vwarning(svinst, ehandler, flags, location, fmt, args);
 	
 	va_end(args);
 }
 
 static inline void sieve_direct_info
-(struct sieve_error_handler *ehandler, const char *location, 
-	const char *fmt, ...)
+(struct sieve_instance *svinst, struct sieve_error_handler *ehandler,
+	unsigned int flags, const char *location, const char *fmt, ...)
 {
 	va_list args;
 	va_start(args, fmt);
 	
-	sieve_direct_vinfo(ehandler, location, fmt, args);
+	sieve_direct_vinfo(svinst, ehandler, flags, location, fmt, args);
 	
 	va_end(args);
 }
 
 static inline void sieve_direct_debug
-(struct sieve_error_handler *ehandler, const char *location,
-	const char *fmt, ...)
+(struct sieve_instance *svinst, struct sieve_error_handler *ehandler,
+	unsigned int flags, const char *location, const char *fmt, ...)
 {
 	va_list args;
 	va_start(args, fmt);
 
-	sieve_direct_vdebug(ehandler, location, fmt, args);
+	sieve_direct_vdebug(svinst, ehandler, flags, location, fmt, args);
 
 	va_end(args);
 }
diff --git a/src/lib-sieve/sieve-error.c b/src/lib-sieve/sieve-error.c
index 0054357a1731c41570eb1ed3e3d65dea262cdc62..083de9510c095c0fe6ee6df1a96ba5dab74e9b7e 100644
--- a/src/lib-sieve/sieve-error.c
+++ b/src/lib-sieve/sieve-error.c
@@ -61,6 +61,110 @@ void sieve_errors_deinit(struct sieve_instance *svinst)
 	sieve_error_handler_unref(&svinst->system_ehandler);
 }
 
+/*
+ * Direct handler calls
+ */
+
+void sieve_direct_verror
+(struct sieve_instance *svinst, struct sieve_error_handler *ehandler, 
+	unsigned int flags, const char *location, const char *fmt, va_list args)
+{
+	if ( (flags & SIEVE_ERROR_FLAG_GLOBAL) != 0 &&
+		(ehandler == NULL || ehandler->parent == NULL) &&
+		svinst->system_ehandler != ehandler &&
+		svinst->system_ehandler->verror != NULL ) {
+		va_list args_copy;
+	
+		VA_COPY(args_copy, args);
+
+		svinst->system_ehandler->verror
+			(svinst->system_ehandler, 0, location, fmt, args_copy);
+	}
+
+	if ( ehandler == NULL ) return;
+
+	if ( ehandler->parent != NULL || sieve_errors_more_allowed(ehandler) ) {
+		if ( ehandler->verror != NULL )
+			ehandler->verror(ehandler, flags, location, fmt, args);
+		
+		if ( ehandler->pool != NULL )
+			ehandler->errors++;
+	}
+}
+
+void sieve_direct_vwarning
+(struct sieve_instance *svinst, struct sieve_error_handler *ehandler,
+	unsigned int flags, const char *location, const char *fmt, va_list args)
+{
+	if ( (flags & SIEVE_ERROR_FLAG_GLOBAL) != 0 &&
+		(ehandler == NULL || ehandler->parent == NULL) && 
+		svinst->system_ehandler != ehandler &&
+		svinst->system_ehandler->vwarning != NULL ) {
+		va_list args_copy;
+	
+		VA_COPY(args_copy, args);
+
+		svinst->system_ehandler->vwarning
+			(svinst->system_ehandler, 0, location, fmt, args_copy);
+	}
+
+	if ( ehandler == NULL ) return;
+
+	if ( ehandler->vwarning != NULL )	
+		ehandler->vwarning(ehandler, flags, location, fmt, args);
+
+	if ( ehandler->pool != NULL )
+		ehandler->warnings++;
+}
+
+void sieve_direct_vinfo
+(struct sieve_instance *svinst, struct sieve_error_handler *ehandler,
+	unsigned int flags, const char *location, const char *fmt, va_list args)
+{
+	if ( (flags & SIEVE_ERROR_FLAG_GLOBAL) != 0 &&
+		(ehandler == NULL || ehandler->parent == NULL) &&
+		svinst->system_ehandler != ehandler &&
+		svinst->system_ehandler->vinfo != NULL ) {
+		va_list args_copy;
+	
+		VA_COPY(args_copy, args);
+
+		svinst->system_ehandler->vinfo
+			(svinst->system_ehandler, 0, location, fmt, args_copy);
+	}
+
+	if ( ehandler == NULL ) return;
+
+	if ( ehandler->parent != NULL || ehandler->log_info ) {
+		if ( ehandler->vinfo != NULL )	
+			ehandler->vinfo(ehandler, flags, location, fmt, args);
+	}
+}
+
+void sieve_direct_vdebug
+(struct sieve_instance *svinst, struct sieve_error_handler *ehandler,
+	unsigned int flags, const char *location, const char *fmt, va_list args)
+{ 
+	if ( (flags & SIEVE_ERROR_FLAG_GLOBAL) != 0 &&
+		(ehandler == NULL || ehandler->parent == NULL) && 
+		svinst->system_ehandler != ehandler &&
+		svinst->system_ehandler->vdebug != NULL ) {
+		va_list args_copy;
+	
+		VA_COPY(args_copy, args);
+
+		svinst->system_ehandler->vdebug
+			(svinst->system_ehandler, 0, location, fmt, args_copy);
+	}
+
+	if ( ehandler == NULL ) return;
+
+	if ( ehandler->parent != NULL || ehandler->log_info ) {
+		if ( ehandler->vdebug != NULL )	
+			ehandler->vdebug(ehandler, flags, location, fmt, args);
+	}
+}
+
 /*
  * System errors
  */
@@ -68,8 +172,8 @@ void sieve_errors_deinit(struct sieve_instance *svinst)
 void sieve_sys_verror
 (struct sieve_instance *svinst, const char *fmt, va_list args)
 {	
-	T_BEGIN { 
-		sieve_verror(svinst->system_ehandler, NULL, fmt, args);
+	T_BEGIN {
+		sieve_direct_verror(svinst, svinst->system_ehandler, 0, NULL, fmt, args);
 	} T_END;
 }
 
@@ -77,7 +181,7 @@ void sieve_sys_vwarning
 (struct sieve_instance *svinst, const char *fmt, va_list args)
 {	
 	T_BEGIN { 
-		sieve_vwarning(svinst->system_ehandler, NULL, fmt, args);
+		sieve_direct_vwarning(svinst, svinst->system_ehandler, 0, NULL, fmt, args);
 	} T_END;
 }
 
@@ -85,7 +189,7 @@ void sieve_sys_vinfo
 (struct sieve_instance *svinst, const char *fmt, va_list args)
 {	
 	T_BEGIN { 
-		sieve_vinfo(svinst->system_ehandler, NULL, fmt, args);
+		sieve_direct_vinfo(svinst, svinst->system_ehandler, 0, NULL, fmt, args);
 	} T_END;
 }
 
@@ -93,7 +197,7 @@ void sieve_sys_vdebug
 (struct sieve_instance *svinst, const char *fmt, va_list args)
 {	
 	T_BEGIN { 
-		sieve_vdebug(svinst->system_ehandler, NULL, fmt, args);
+		sieve_direct_vdebug(svinst, svinst->system_ehandler, 0, NULL, fmt, args);
 	} T_END;
 }
 
@@ -103,7 +207,7 @@ void sieve_sys_error(struct sieve_instance *svinst, const char *fmt, ...)
 	va_start(args, fmt);
 	
 	T_BEGIN { 
-		sieve_verror(svinst->system_ehandler, NULL, fmt, args);
+		sieve_direct_verror(svinst, svinst->system_ehandler, 0, NULL, fmt, args);
 	} T_END;
 	
 	va_end(args);
@@ -115,7 +219,7 @@ void sieve_sys_warning(struct sieve_instance *svinst, const char *fmt, ...)
 	va_start(args, fmt);
 	
 	T_BEGIN {
-		sieve_vwarning(svinst->system_ehandler, NULL, fmt, args);
+		sieve_direct_vwarning(svinst, svinst->system_ehandler, 0, NULL, fmt, args);
 	} T_END;
 	
 	va_end(args);
@@ -127,7 +231,7 @@ void sieve_sys_info(struct sieve_instance *svinst, const char *fmt, ...)
 	va_start(args, fmt);
 	
 	T_BEGIN {
-		sieve_vinfo(svinst->system_ehandler, NULL, fmt, args);
+		sieve_direct_vinfo(svinst, svinst->system_ehandler, 0, NULL, fmt, args);
 	} T_END;
 	
 	va_end(args);
@@ -139,7 +243,7 @@ void sieve_sys_debug(struct sieve_instance *svinst, const char *fmt, ...)
 	va_start(args, fmt);
 	
 	T_BEGIN {
-		sieve_vdebug(svinst->system_ehandler, NULL, fmt, args);
+		sieve_direct_vdebug(svinst, svinst->system_ehandler, 0, NULL, fmt, args);
 	} T_END;
 	
 	va_end(args);
@@ -159,152 +263,140 @@ void sieve_system_ehandler_set
  * User errors
  */
 
-void sieve_user_verror
-(struct sieve_error_handler *ehandler, const char *location, 
-	const char *fmt, va_list args)
+void sieve_global_verror
+(struct sieve_instance *svinst, struct sieve_error_handler *ehandler,
+	const char *location, const char *fmt, va_list args)
 {
-	if ( ehandler == NULL ) return;
-	
-	sieve_direct_verror(ehandler, location, fmt, args);
+	sieve_direct_verror
+		(svinst, ehandler, SIEVE_ERROR_FLAG_GLOBAL, location, fmt, args);
 }
 
-void sieve_user_vwarning
-(struct sieve_error_handler *ehandler, const char *location, 
-	const char *fmt, va_list args)
+void sieve_global_vwarning
+(struct sieve_instance *svinst, struct sieve_error_handler *ehandler,
+	const char *location, const char *fmt, va_list args)
 {
-	if ( ehandler == NULL ) return;
-
-	sieve_direct_vwarning(ehandler, location, fmt, args);
+	sieve_direct_vwarning
+		(svinst, ehandler, SIEVE_ERROR_FLAG_GLOBAL, location, fmt, args);
 }
 
-void sieve_user_vinfo
-(struct sieve_error_handler *ehandler, const char *location, 
-	const char *fmt, va_list args)
+void sieve_global_vinfo
+(struct sieve_instance *svinst, struct sieve_error_handler *ehandler,
+	const char *location, const char *fmt, va_list args)
 {
-	if ( ehandler == NULL ) return;
-
-	sieve_direct_vinfo(ehandler, location, fmt, args);
+	sieve_direct_vinfo
+		(svinst, ehandler, SIEVE_ERROR_FLAG_GLOBAL, location, fmt, args);
 }
 
-void sieve_user_error
-(struct sieve_error_handler *ehandler, const char *location, 
-	const char *fmt, ...)
+void sieve_global_error
+(struct sieve_instance *svinst, struct sieve_error_handler *ehandler, 
+	const char *location, const char *fmt, ...)
 {
 	va_list args;
 	va_start(args, fmt);
 	
-	T_BEGIN { sieve_user_verror(ehandler, location, fmt, args); } T_END;
+	T_BEGIN {
+		sieve_global_verror(svinst, ehandler, location, fmt, args); 
+	} T_END;
 	
 	va_end(args);
 }
 
-void sieve_user_warning
-(struct sieve_error_handler *ehandler, const char *location, 
-	const char *fmt, ...)
+void sieve_global_warning
+(struct sieve_instance *svinst, struct sieve_error_handler *ehandler, 
+	const char *location, const char *fmt, ...)
 {
 	va_list args;
 	va_start(args, fmt);
 	
-	T_BEGIN { sieve_user_vwarning(ehandler, location, fmt, args); } T_END;
-
+	T_BEGIN {
+		sieve_global_vwarning(svinst, ehandler, location, fmt, args); 
+	} T_END;
+	
 	va_end(args);
 }
 
-void sieve_user_info
-(struct sieve_error_handler *ehandler, const char *location, 
-	const char *fmt, ...)
+void sieve_global_info
+(struct sieve_instance *svinst, struct sieve_error_handler *ehandler, 
+	const char *location, const char *fmt, ...)
 {
 	va_list args;
 	va_start(args, fmt);
 	
-	T_BEGIN { sieve_user_vinfo(ehandler, location, fmt, args); } T_END;
+	T_BEGIN {
+		sieve_global_vinfo(svinst, ehandler, location, fmt, args); 
+	} T_END;
 	
 	va_end(args);
 }
 
 /*
- * Main error functions
+ * Default (user) error functions
  */
 
-static void sieve_vcopy_master
-(struct sieve_instance *svinst, const char *location,
-	sieve_error_vfunc_t error_vfunc, const char *fmt, va_list args)
-{
-	va_list args_copy;
-
-	VA_COPY(args_copy, args);
-
-	error_vfunc(svinst->system_ehandler, location, fmt, args_copy);
-}
-
 void sieve_verror
-	(struct sieve_error_handler *ehandler, const char *location, 
-		const char *fmt, va_list args)
-{
+(struct sieve_error_handler *ehandler, const char *location, 
+	const char *fmt, va_list args)
+{	
 	if ( ehandler == NULL ) return;
-	
-	if ( ehandler->parent == NULL && ehandler->log_master )
-		sieve_vcopy_master(ehandler->svinst, location, sieve_verror, fmt, args);
 
-	sieve_direct_verror(ehandler, location, fmt, args);
+	sieve_direct_verror(ehandler->svinst, ehandler, 0, location, fmt, args);
 }
 
 void sieve_vwarning
-	(struct sieve_error_handler *ehandler, const char *location, 
-		const char *fmt, va_list args)
+(struct sieve_error_handler *ehandler, const char *location, 
+	const char *fmt, va_list args)
 {
 	if ( ehandler == NULL ) return;
 
-	if ( ehandler->parent == NULL && ehandler->log_master )
-		sieve_vcopy_master(ehandler->svinst, location, sieve_vwarning, fmt, args);
-
-	sieve_direct_vwarning(ehandler, location, fmt, args);
+	sieve_direct_vwarning(ehandler->svinst, ehandler, 0, location, fmt, args);
 }
 
 void sieve_vinfo
-	(struct sieve_error_handler *ehandler, const char *location, 
-		const char *fmt, va_list args)
+(struct sieve_error_handler *ehandler, const char *location, 
+	const char *fmt, va_list args)
 {
 	if ( ehandler == NULL ) return;
 
-	if ( ehandler->parent == NULL && ehandler->log_master )
-		sieve_vcopy_master(ehandler->svinst, location, sieve_vinfo, fmt, args);
-
-	sieve_direct_vinfo(ehandler, location, fmt, args);
+	sieve_direct_vinfo(ehandler->svinst, ehandler, 0, location, fmt, args);
 }
 
 void sieve_vdebug
-	(struct sieve_error_handler *ehandler, const char *location,
-		const char *fmt, va_list args)
+(struct sieve_error_handler *ehandler, const char *location,
+	const char *fmt, va_list args)
 {
 	if ( ehandler == NULL ) return;
 
-	if ( ehandler->parent == NULL && ehandler->log_master )
-		sieve_vcopy_master(ehandler->svinst, location, sieve_vdebug, fmt, args);
-
-	sieve_direct_vdebug(ehandler, location, fmt, args);
+	sieve_direct_vdebug(ehandler->svinst, ehandler, 0, location, fmt, args);
 }
 
 void sieve_vcritical
 (struct sieve_instance *svinst, struct sieve_error_handler *ehandler,
-	const char *location, const char *fmt, va_list args)
+	const char *location, const char *prefix, const char *fmt, va_list args)
 {
 	char str[256];
 	struct tm *tm; 
 		
 	if ( location == NULL || *location == '\0' ) {
-		sieve_verror(svinst->system_ehandler, NULL, fmt, args);
+		sieve_direct_verror
+			(svinst, svinst->system_ehandler, 0, NULL, fmt, args);
 	} else {
-		sieve_verror(svinst->system_ehandler, location, fmt, args);
+		sieve_direct_verror
+			(svinst, svinst->system_ehandler, 0, location, fmt, args);
 	}
 
 	if ( ehandler == NULL ) return;
 
 	tm = localtime(&ioloop_time);
 	
-	sieve_error(ehandler, location, "%s", 
-		strftime(str, sizeof(str), CRITICAL_MSG_STAMP, tm) > 0 ? 
-			str : CRITICAL_MSG );	
+	if ( prefix == NULL || *prefix == '\0' ) {
+		sieve_direct_error(svinst, ehandler, 0, location, "%s",  
+			( strftime(str, sizeof(str), CRITICAL_MSG_STAMP, tm) > 0 ? 
+				str : CRITICAL_MSG ));	
+	} else { 
+		sieve_direct_error(svinst, ehandler, 0, location, "%s: %s", prefix,  
+			( strftime(str, sizeof(str), CRITICAL_MSG_STAMP, tm) > 0 ? 
+				str : CRITICAL_MSG ));
+	}	
 }
 
 void sieve_error
@@ -357,12 +449,14 @@ void sieve_debug
 
 void sieve_critical
 (struct sieve_instance *svinst, struct sieve_error_handler *ehandler,
-	const char *location, const char *fmt, ...)
+	const char *location, const char *prefix, const char *fmt, ...)
 {
 	va_list args;
 	va_start(args, fmt);
 	
-	T_BEGIN { sieve_vcritical(svinst, ehandler, location, fmt, args); } T_END;
+	T_BEGIN {
+		sieve_vcritical(svinst, ehandler, location, prefix, fmt, args);
+	} T_END;
 	
 	va_end(args);
 }
@@ -415,15 +509,6 @@ void sieve_error_handler_accept_debuglog
 	}
 }
 
-void sieve_error_handler_copy_masterlog
-(struct sieve_error_handler *ehandler, bool enable)
-{
-	while ( ehandler != NULL ) {
-		ehandler->log_master = enable;
-		ehandler = ehandler->parent;
-	}
-}
-
 /*
  * Error handler init
  */
@@ -451,7 +536,6 @@ void sieve_error_handler_init_from_parent
 	ehandler->parent = parent;
 	sieve_error_handler_ref(parent);
 
-	ehandler->log_master = parent->log_master;
 	ehandler->log_info = parent->log_info;
 	ehandler->log_debug = parent->log_debug;
 }
@@ -498,11 +582,10 @@ void sieve_error_handler_reset(struct sieve_error_handler *ehandler)
  */
 
 static void sieve_master_verror
-(struct sieve_error_handler *ehandler, const char *location, 
-	const char *fmt, va_list args) 
+(struct sieve_error_handler *ehandler ATTR_UNUSED,
+	unsigned int flags ATTR_UNUSED, const char *location, const char *fmt,
+	va_list args) 
 {
-	if ( ehandler->log_master ) return;
-
 	if ( location == NULL || *location == '\0' )
 		i_error("sieve: %s", t_strdup_vprintf(fmt, args));
 	else
@@ -510,11 +593,10 @@ static void sieve_master_verror
 }
 
 static void sieve_master_vwarning
-(struct sieve_error_handler *ehandler ATTR_UNUSED, const char *location, 
-	const char *fmt, va_list args) 
+(struct sieve_error_handler *ehandler ATTR_UNUSED,
+	unsigned int flags ATTR_UNUSED, const char *location, const char *fmt,
+	va_list args) 
 {
-	if ( ehandler->log_master ) return;
-
 	if ( location == NULL || *location == '\0' )
 		i_warning("sieve: %s", t_strdup_vprintf(fmt, args));
 	else
@@ -522,11 +604,10 @@ static void sieve_master_vwarning
 }
 
 static void sieve_master_vinfo
-(struct sieve_error_handler *ehandler ATTR_UNUSED, const char *location, 
-	const char *fmt, va_list args) 
+(struct sieve_error_handler *ehandler ATTR_UNUSED,
+	unsigned int flags ATTR_UNUSED, const char *location, const char *fmt,
+	va_list args) 
 {
-	if ( ehandler->log_master ) return;
-
 	if ( location == NULL || *location == '\0' )
 		i_info("sieve: %s", t_strdup_vprintf(fmt, args));
 	else
@@ -534,11 +615,10 @@ static void sieve_master_vinfo
 }
 
 static void sieve_master_vdebug
-(struct sieve_error_handler *ehandler ATTR_UNUSED, const char *location,
-	const char *fmt, va_list args) 
+(struct sieve_error_handler *ehandler ATTR_UNUSED,
+	unsigned int flags ATTR_UNUSED, const char *location, const char *fmt,
+	va_list args) 
 {
-	if ( ehandler->log_master ) return;
-
 	if ( location == NULL || *location == '\0' )
 		i_debug("sieve: %s", t_strdup_vprintf(fmt, args));
 	else
@@ -584,29 +664,29 @@ static void sieve_stderr_vmessage
 }
 
 static void sieve_stderr_verror
-(struct sieve_error_handler *ehandler, const char *location,
-	const char *fmt, va_list args) 
+(struct sieve_error_handler *ehandler, unsigned int flags ATTR_UNUSED,
+	const char *location, const char *fmt, va_list args) 
 {
 	sieve_stderr_vmessage(ehandler, "error", location, fmt, args);
 }
 
 static void sieve_stderr_vwarning
-(struct sieve_error_handler *ehandler, const char *location,
-	const char *fmt, va_list args) 
+(struct sieve_error_handler *ehandler, unsigned int flags ATTR_UNUSED, 
+	const char *location, const char *fmt, va_list args) 
 {
 	sieve_stderr_vmessage(ehandler, "warning", location, fmt, args);
 }
 
 static void sieve_stderr_vinfo
-(struct sieve_error_handler *ehandler, const char *location,
-	const char *fmt, va_list args) 
+(struct sieve_error_handler *ehandler, unsigned int flags ATTR_UNUSED, 
+	const char *location, const char *fmt, va_list args) 
 {
 	sieve_stderr_vmessage(ehandler, "info", location, fmt, args);
 }
 
 static void sieve_stderr_vdebug
-(struct sieve_error_handler *ehandler, const char *location,
-	const char *fmt, va_list args) 
+(struct sieve_error_handler *ehandler, unsigned int flags ATTR_UNUSED, 
+	const char *location, const char *fmt, va_list args) 
 {
 	sieve_stderr_vmessage(ehandler, "debug", location, fmt, args);
 }
@@ -664,29 +744,29 @@ static void sieve_strbuf_vmessage
 }
 
 static void sieve_strbuf_verror
-(struct sieve_error_handler *ehandler, const char *location,
-    const char *fmt, va_list args)
+(struct sieve_error_handler *ehandler, unsigned int flags ATTR_UNUSED, 
+	const char *location, const char *fmt, va_list args)
 {
 	sieve_strbuf_vmessage(ehandler, "error", location, fmt, args);
 }
 
 static void sieve_strbuf_vwarning
-(struct sieve_error_handler *ehandler, const char *location,
-    const char *fmt, va_list args)
+(struct sieve_error_handler *ehandler, unsigned int flags ATTR_UNUSED, 
+	const char *location, const char *fmt, va_list args)
 {
 	sieve_strbuf_vmessage(ehandler, "warning", location, fmt, args);
 }
 
 static void sieve_strbuf_vinfo
-(struct sieve_error_handler *ehandler, const char *location,
-    const char *fmt, va_list args)
+(struct sieve_error_handler *ehandler, unsigned int flags ATTR_UNUSED, 
+	const char *location, const char *fmt, va_list args)
 {
 	sieve_strbuf_vmessage(ehandler, "info", location, fmt, args);
 }
 
 static void sieve_strbuf_vdebug
-(struct sieve_error_handler *ehandler, const char *location,
-    const char *fmt, va_list args)
+(struct sieve_error_handler *ehandler, unsigned int flags ATTR_UNUSED, 
+	const char *location, const char *fmt, va_list args)
 {
 	sieve_strbuf_vmessage(ehandler, "debug", location, fmt, args);
 }
@@ -874,8 +954,8 @@ static void sieve_logfile_start(struct sieve_logfile_ehandler *ehandler)
 }
 
 static void sieve_logfile_verror
-(struct sieve_error_handler *ehandler, const char *location, 
-	const char *fmt, va_list args) 
+(struct sieve_error_handler *ehandler, unsigned int flags ATTR_UNUSED, 
+	const char *location, const char *fmt, va_list args) 
 {
 	struct sieve_logfile_ehandler *handler = 
 		(struct sieve_logfile_ehandler *) ehandler;
@@ -886,8 +966,8 @@ static void sieve_logfile_verror
 }
 
 static void sieve_logfile_vwarning
-(struct sieve_error_handler *ehandler, const char *location, 
-	const char *fmt, va_list args) 
+(struct sieve_error_handler *ehandler, unsigned int flags ATTR_UNUSED, 
+	const char *location, const char *fmt, va_list args) 
 {
 	struct sieve_logfile_ehandler *handler = 
 		(struct sieve_logfile_ehandler *) ehandler;
@@ -898,8 +978,8 @@ static void sieve_logfile_vwarning
 }
 
 static void sieve_logfile_vinfo
-(struct sieve_error_handler *ehandler, const char *location, 
-	const char *fmt, va_list args) 
+(struct sieve_error_handler *ehandler, unsigned int flags ATTR_UNUSED, 
+	const char *location, const char *fmt, va_list args) 
 {
 	struct sieve_logfile_ehandler *handler = 
 		(struct sieve_logfile_ehandler *) ehandler;
@@ -910,8 +990,8 @@ static void sieve_logfile_vinfo
 }
 
 static void sieve_logfile_vdebug
-(struct sieve_error_handler *ehandler, const char *location,
-	const char *fmt, va_list args)
+(struct sieve_error_handler *ehandler, unsigned int flags ATTR_UNUSED, 
+	const char *location, const char *fmt, va_list args)
 {
 	struct sieve_logfile_ehandler *handler =
 		(struct sieve_logfile_ehandler *) ehandler;
@@ -997,55 +1077,47 @@ static const char *_prefix_message
 }
 
 static void sieve_prefix_verror
-(struct sieve_error_handler *_ehandler, const char *location,
-	const char *fmt, va_list args) 
+(struct sieve_error_handler *_ehandler, unsigned int flags,
+	const char *location, const char *fmt, va_list args) 
 {	
-    struct sieve_prefix_ehandler *ehandler =
-        (struct sieve_prefix_ehandler *) _ehandler;
-
-	if ( _ehandler->parent == NULL ) return;
+	struct sieve_prefix_ehandler *ehandler =
+		(struct sieve_prefix_ehandler *) _ehandler;
 
-	sieve_error(_ehandler->parent, ehandler->location, "%s",
-		_prefix_message(ehandler, location, fmt, args)); 
+	sieve_direct_error(_ehandler->svinst, _ehandler->parent, flags,
+		ehandler->location, "%s", _prefix_message(ehandler, location, fmt, args)); 
 }
 
 static void sieve_prefix_vwarning
-(struct sieve_error_handler *_ehandler, const char *location,
-	const char *fmt, va_list args) 
+(struct sieve_error_handler *_ehandler, unsigned int flags, 
+	const char *location, const char *fmt, va_list args) 
 {
-    struct sieve_prefix_ehandler *ehandler =
-        (struct sieve_prefix_ehandler *) _ehandler;
+	struct sieve_prefix_ehandler *ehandler =
+		(struct sieve_prefix_ehandler *) _ehandler;
 
-	if ( _ehandler->parent == NULL ) return;
-
-	sieve_warning(_ehandler->parent, ehandler->location, "%s",
-		_prefix_message(ehandler, location, fmt, args)); 
+	sieve_direct_warning(_ehandler->svinst, _ehandler->parent, flags,
+		ehandler->location, "%s", _prefix_message(ehandler, location, fmt, args)); 
 }
 
 static void sieve_prefix_vinfo
-(struct sieve_error_handler *_ehandler, const char *location,
-	const char *fmt, va_list args) 
+(struct sieve_error_handler *_ehandler, unsigned int flags,
+	const char *location, const char *fmt, va_list args) 
 {
-    struct sieve_prefix_ehandler *ehandler =
-        (struct sieve_prefix_ehandler *) _ehandler;
+	struct sieve_prefix_ehandler *ehandler =
+		(struct sieve_prefix_ehandler *) _ehandler;
 
-	if ( _ehandler->parent == NULL ) return;
-
-	sieve_direct_info(_ehandler->parent, ehandler->location, "%s",
-		_prefix_message(ehandler, location, fmt, args)); 
+	sieve_direct_info(_ehandler->svinst, _ehandler->parent, flags,
+		ehandler->location, "%s", _prefix_message(ehandler, location, fmt, args)); 
 }
 
 static void sieve_prefix_vdebug
-(struct sieve_error_handler *_ehandler, const char *location,
-	const char *fmt, va_list args) 
+(struct sieve_error_handler *_ehandler, unsigned int flags, 
+	const char *location, const char *fmt, va_list args) 
 {
-    struct sieve_prefix_ehandler *ehandler =
-        (struct sieve_prefix_ehandler *) _ehandler;
-
-	if ( _ehandler->parent == NULL ) return;
+	struct sieve_prefix_ehandler *ehandler =
+		(struct sieve_prefix_ehandler *) _ehandler;
 
-	sieve_direct_debug(_ehandler->parent, ehandler->location, "%s",
-		_prefix_message(ehandler, location, fmt, args)); 
+	sieve_direct_debug(_ehandler->svinst, _ehandler->parent, flags, 
+		ehandler->location, "%s", _prefix_message(ehandler, location, fmt, args)); 
 }
 
 struct sieve_error_handler *sieve_prefix_ehandler_create
@@ -1090,10 +1162,11 @@ static const char *_expand_message
 (struct sieve_error_handler *_ehandler,
 	const char *location, const char *fmt, va_list args) 
 {
-    struct sieve_varexpand_ehandler *ehandler =
-        (struct sieve_varexpand_ehandler *) _ehandler;
+	struct sieve_varexpand_ehandler *ehandler =
+		(struct sieve_varexpand_ehandler *) _ehandler;
 	unsigned int count;
-	struct var_expand_table *table = array_get_modifiable(&ehandler->table, &count);
+	struct var_expand_table *table =
+		array_get_modifiable(&ehandler->table, &count);
 	string_t *str = t_str_new(256);
 
 	/* Fill in substitution items */
@@ -1107,43 +1180,35 @@ static const char *_expand_message
 }
 
 static void sieve_varexpand_verror
-(struct sieve_error_handler *ehandler, const char *location,
-	const char *fmt, va_list args) 
+(struct sieve_error_handler *ehandler, unsigned int flags,
+	const char *location, const char *fmt, va_list args) 
 {	
-	if ( ehandler->parent == NULL ) return;
-
-	sieve_error(ehandler->parent, location, "%s",
-		_expand_message(ehandler, location, fmt, args)); 
+	sieve_direct_error(ehandler->svinst, ehandler->parent, flags, location,
+		"%s", _expand_message(ehandler, location, fmt, args)); 
 }
 
 static void sieve_varexpand_vwarning
-(struct sieve_error_handler *ehandler, const char *location,
-	const char *fmt, va_list args) 
+(struct sieve_error_handler *ehandler, unsigned int flags,
+	const char *location, const char *fmt, va_list args) 
 {
-	if ( ehandler->parent == NULL ) return;
-
-	sieve_warning(ehandler->parent, location, "%s",
-		_expand_message(ehandler, location, fmt, args)); 
+	sieve_direct_warning(ehandler->svinst, ehandler->parent, flags, location, 
+		"%s", _expand_message(ehandler, location, fmt, args)); 
 }
 
 static void sieve_varexpand_vinfo
-(struct sieve_error_handler *ehandler, const char *location,
-	const char *fmt, va_list args) 
+(struct sieve_error_handler *ehandler, unsigned int flags,
+	const char *location, const char *fmt, va_list args) 
 {
-	if ( ehandler->parent == NULL ) return;
-
-	sieve_info(ehandler->parent, location, "%s",
-		_expand_message(ehandler, location, fmt, args)); 
+	sieve_direct_info(ehandler->svinst, ehandler->parent, flags, location,
+		"%s", _expand_message(ehandler, location, fmt, args)); 
 }
 
 static void sieve_varexpand_vdebug
-(struct sieve_error_handler *ehandler, const char *location,
-	const char *fmt, va_list args) 
+(struct sieve_error_handler *ehandler, unsigned int flags,
+	const char *location, const char *fmt, va_list args) 
 {
-	if ( ehandler->parent == NULL ) return;
-
-	sieve_direct_debug(ehandler->parent, location, "%s",
-		_expand_message(ehandler, location, fmt, args)); 
+	sieve_direct_debug(ehandler->svinst, ehandler->parent, flags, location,
+		"%s", _expand_message(ehandler, location, fmt, args)); 
 }
 
 struct sieve_error_handler *sieve_varexpand_ehandler_create
diff --git a/src/lib-sieve/sieve-error.h b/src/lib-sieve/sieve-error.h
index 752d2c71eaf7f7abcd5e4f97b37411844d1ff7a5..36e8985b026b42e7b4c4602b005394f4b5b37164 100644
--- a/src/lib-sieve/sieve-error.h
+++ b/src/lib-sieve/sieve-error.h
@@ -56,31 +56,31 @@ void sieve_system_ehandler_set
 	(struct sieve_error_handler *ehandler);
 
 /*
- * User errors
+ * Global (user+system) errors
  */
 
-void sieve_user_verror
-	(struct sieve_error_handler *ehandler, const char *location, 
-		const char *fmt, va_list args);
-void sieve_user_vwarning
-	(struct sieve_error_handler *ehandler, const char *location, 
-		const char *fmt, va_list args); 
-void sieve_user_vinfo
-	(struct sieve_error_handler *ehandler, const char *location, 
-		const char *fmt, va_list args); 
+void sieve_global_verror
+	(struct sieve_instance *svinst, struct sieve_error_handler *ehandler,
+		const char *location, const char *fmt, va_list args);
+void sieve_global_vwarning
+	(struct sieve_instance *svinst, struct sieve_error_handler *ehandler,
+		const char *location, const char *fmt, va_list args);
+void sieve_global_vinfo
+	(struct sieve_instance *svinst, struct sieve_error_handler *ehandler,
+		const char *location, const char *fmt, va_list args);
 
-void sieve_user_error
-(struct sieve_error_handler *ehandler, const char *location, 
-	const char *fmt, ...) ATTR_FORMAT(3, 4);
-void sieve_user_warning
-(struct sieve_error_handler *ehandler, const char *location, 
-	const char *fmt, ...) ATTR_FORMAT(3, 4);
-void sieve_user_info
-(struct sieve_error_handler *ehandler, const char *location, 
-	const char *fmt, ...) ATTR_FORMAT(3, 4);
+void sieve_global_error
+	(struct sieve_instance *svinst, struct sieve_error_handler *ehandler,
+		const char *location, const char *fmt, ...) ATTR_FORMAT(4, 5);
+void sieve_global_warning
+	(struct sieve_instance *svinst, struct sieve_error_handler *ehandler,
+		const char *location, const char *fmt, ...) ATTR_FORMAT(4, 5);
+void sieve_global_info
+	(struct sieve_instance *svinst, struct sieve_error_handler *ehandler,
+		const char *location, const char *fmt, ...) ATTR_FORMAT(4, 5);
 
 /*
- * Main error functions
+ * Main (user) error functions
  */
 
 /* For these functions it is the responsibility of the caller to
@@ -104,23 +104,24 @@ void sieve_vdebug
 		const char *fmt, va_list args);
 void sieve_vcritical
 	(struct sieve_instance *svinst, struct sieve_error_handler *ehandler,
-		const char *location, const char *fmt, va_list args);
+		const char *location, const char *prefix, const char *fmt, va_list args);
 
 void sieve_error
-(struct sieve_error_handler *ehandler, const char *location, 
-	const char *fmt, ...) ATTR_FORMAT(3, 4);
+	(struct sieve_error_handler *ehandler, const char *location, 
+		const char *fmt, ...) ATTR_FORMAT(3, 4);
 void sieve_warning
-(struct sieve_error_handler *ehandler, const char *location, 
-	const char *fmt, ...) ATTR_FORMAT(3, 4);
+	(struct sieve_error_handler *ehandler, const char *location, 
+		const char *fmt, ...) ATTR_FORMAT(3, 4);
 void sieve_info
-(struct sieve_error_handler *ehandler, const char *location, 
-	const char *fmt, ...) ATTR_FORMAT(3, 4);
+	(struct sieve_error_handler *ehandler, const char *location, 
+		const char *fmt, ...) ATTR_FORMAT(3, 4);
 void sieve_debug
-(struct sieve_error_handler *ehandler, const char *location,
-	const char *fmt, ...) ATTR_FORMAT(3, 4);
+	(struct sieve_error_handler *ehandler, const char *location,
+		const char *fmt, ...) ATTR_FORMAT(3, 4);
 void sieve_critical
-(struct sieve_instance *svinst, struct sieve_error_handler *ehandler,
-	const char *location, const char *fmt, ...) ATTR_FORMAT(4, 5);
+	(struct sieve_instance *svinst, struct sieve_error_handler *ehandler,
+		const char *location, const char *prefix, const char *fmt, ...)
+		ATTR_FORMAT(5, 6);
 
 /*
  * Error handler configuration
diff --git a/src/lib-sieve/sieve-interpreter.c b/src/lib-sieve/sieve-interpreter.c
index 61f8dce90f0aa1f71a5f68f00e79a202941c00d9..92e66fe7a09bfabb7b71277b2f97c8b50479f78a 100644
--- a/src/lib-sieve/sieve-interpreter.c
+++ b/src/lib-sieve/sieve-interpreter.c
@@ -290,7 +290,7 @@ void sieve_runtime_error
 	va_list args;
 
 	va_start(args, fmt);
-	sieve_runtime_vmsg(renv, sieve_user_verror, location, fmt, args);
+	sieve_runtime_vmsg(renv, sieve_verror, location, fmt, args);
 	va_end(args);
 }
 
@@ -301,7 +301,7 @@ void sieve_runtime_warning
 	va_list args;
 
 	va_start(args, fmt);
-	sieve_runtime_vmsg(renv, sieve_user_vwarning, location, fmt, args);
+	sieve_runtime_vmsg(renv, sieve_vwarning, location, fmt, args);
 	va_end(args);
 }
 
@@ -312,7 +312,7 @@ void sieve_runtime_log
 	va_list args;
 
 	va_start(args, fmt);
-	sieve_runtime_vmsg(renv, sieve_user_vinfo, location, fmt, args);
+	sieve_runtime_vmsg(renv, sieve_vinfo, location, fmt, args);
 	va_end(args);
 }
 
diff --git a/src/lib-sieve/sieve-result.c b/src/lib-sieve/sieve-result.c
index 2e332d7c6cd5eba706e757cf26e7761d3bb04d04..349a8ecaf6e2978d6e25c53c5d452de3854b07c2 100644
--- a/src/lib-sieve/sieve-result.c
+++ b/src/lib-sieve/sieve-result.c
@@ -113,6 +113,7 @@ struct sieve_result *sieve_result_create
 		sieve_error_handler_ref(ehandler);	
 	result->ehandler = ehandler;
 
+	result->action_env.svinst = svinst;
 	result->action_env.result = result;
 	result->action_env.scriptenv = senv;
 	result->action_env.msgdata = msgdata;
@@ -240,13 +241,13 @@ void sieve_result_error
 	va_end(args);
 }
 
-void sieve_result_user_error
+void sieve_result_global_error
 (const struct sieve_action_exec_env *aenv, const char *fmt, ...)
 {
 	va_list args;
 	
 	va_start(args, fmt);	
-	sieve_user_verror(aenv->ehandler, NULL, fmt, args); 
+	sieve_global_verror(aenv->svinst, aenv->ehandler, NULL, fmt, args); 
 	va_end(args);
 }
 
@@ -260,13 +261,13 @@ void sieve_result_warning
 	va_end(args);
 }
 
-void sieve_result_user_warning
+void sieve_result_global_warning
 (const struct sieve_action_exec_env *aenv, const char *fmt, ...)
 {
 	va_list args;
 	
 	va_start(args, fmt);	
-	sieve_user_vwarning(aenv->ehandler, NULL, fmt, args);
+	sieve_global_vwarning(aenv->svinst, aenv->ehandler, NULL, fmt, args);
 	va_end(args);
 }
 
@@ -281,6 +282,16 @@ void sieve_result_log
 	va_end(args);
 }
 
+void sieve_result_global_log
+(const struct sieve_action_exec_env *aenv, const char *fmt, ...)
+{
+	va_list args;
+	
+	va_start(args, fmt);	
+	sieve_global_vinfo(aenv->svinst, aenv->ehandler, NULL, fmt, args);
+	va_end(args);
+}
+
 /* 
  * Result composition 
  */
diff --git a/src/lib-sieve/sieve-result.h b/src/lib-sieve/sieve-result.h
index 2ce25767ed241d61130d8e9f99041f95b4f7fe69..9ee90a534057c48c27b84c719dd0ff3ae709b9c2 100644
--- a/src/lib-sieve/sieve-result.h
+++ b/src/lib-sieve/sieve-result.h
@@ -89,16 +89,19 @@ bool sieve_result_print
 void sieve_result_error
 (const struct sieve_action_exec_env *aenv, const char *fmt, ...)
 	ATTR_FORMAT(2, 3);
-void sieve_result_user_error
+void sieve_result_global_error
 (const struct sieve_action_exec_env *aenv, const char *fmt, ...)
 	ATTR_FORMAT(2, 3);
 void sieve_result_warning
 (const struct sieve_action_exec_env *aenv, const char *fmt, ...)
 	ATTR_FORMAT(2, 3);
-void sieve_result_user_warning
+void sieve_result_global_warning
 (const struct sieve_action_exec_env *aenv, const char *fmt, ...)
 	ATTR_FORMAT(2, 3);
 void sieve_result_log
+(const struct sieve_action_exec_env *aenv, const char *fmt, ...)
+	ATTR_FORMAT(2, 3);
+void sieve_result_global_log
 (const struct sieve_action_exec_env *aenv, const char *fmt, ...)
 	ATTR_FORMAT(2, 3);
 
diff --git a/src/lib-sieve/sieve-script.c b/src/lib-sieve/sieve-script.c
index 4ecc78611cc4e40e3c36cad3713fcf1ecf75d1e6..ac4f5a7e4c57b3533e28509ed93de40027ea080c 100644
--- a/src/lib-sieve/sieve-script.c
+++ b/src/lib-sieve/sieve-script.c
@@ -147,14 +147,13 @@ static void sieve_script_handle_file_error
 		}
 		break;
 	case EACCES:
-		sieve_critical(svinst, ehandler, name, 
-			"failed to stat sieve script: %s",
-			eacces_error_get("stat", path));
+		sieve_critical(svinst, ehandler, name, "failed to open sieve script", 
+			"failed to stat sieve script: %s", eacces_error_get("stat", path));
 		if ( error_r != NULL )
 			*error_r = SIEVE_ERROR_NO_PERM;
 		break;
 	default:
-		sieve_critical(svinst, ehandler, name, 
+		sieve_critical(svinst, ehandler, name, "failed to open sieve script", 
 			"failed to stat sieve script: stat(%s) failed: %m", path);
 		if ( error_r != NULL )
 			*error_r = SIEVE_ERROR_TEMP_FAIL;
@@ -229,6 +228,7 @@ struct sieve_script *sieve_script_init
 
 			if ( ret == 0 && !S_ISREG(st.st_mode) ) {
 				sieve_critical(svinst, ehandler, basename, 
+					"failed to open sieve script",
 					"sieve script file '%s' is not a regular file.", path);
 				if ( error_r != NULL )
 					*error_r = SIEVE_ERROR_NOT_POSSIBLE;
@@ -380,7 +380,8 @@ struct istream *sieve_script_open
 	}	
 	
 	if ( fstat(fd, &st) != 0 ) {
-		sieve_critical(script->svinst, script->ehandler, script->path, 
+		sieve_critical(script->svinst, script->ehandler, script->basename,
+			"failed to open sieve script",
 			"failed to open sieve script: fstat(fd=%s) failed: %m", script->path);
 		if ( error_r != NULL )
 			*error_r = SIEVE_ERROR_TEMP_FAIL;
@@ -388,7 +389,8 @@ struct istream *sieve_script_open
 	} else {
 		/* Re-check the file type just to be sure */
 		if ( !S_ISREG(st.st_mode) ) {
-			sieve_critical(script->svinst, script->ehandler, script->path,
+			sieve_critical(script->svinst, script->ehandler, script->basename,
+				"failed to open sieve script",
 				"sieve script file '%s' is not a regular file", script->path);
 			if ( error_r != NULL )
 				*error_r = SIEVE_ERROR_NOT_POSSIBLE;
diff --git a/src/lib-sievestorage/sieve-storage.c b/src/lib-sievestorage/sieve-storage.c
index e5478835edc1182111ab6cd9cc9bb7bfe1a8fe42..7e7bd0558b962cb4db04a619de5e5aeb46c04e05 100644
--- a/src/lib-sievestorage/sieve-storage.c
+++ b/src/lib-sievestorage/sieve-storage.c
@@ -31,8 +31,9 @@
 #define CRITICAL_MSG_STAMP CRITICAL_MSG " [%Y-%m-%d %H:%M:%S]"
 
 static void sieve_storage_verror
-	(struct sieve_error_handler *ehandler ATTR_UNUSED, 
-		const char *location ATTR_UNUSED, const char *fmt, va_list args);
+	(struct sieve_error_handler *ehandler ATTR_UNUSED,
+		unsigned int flags ATTR_UNUSED, const char *location ATTR_UNUSED,
+		const char *fmt, va_list args);
 
 static const char *sieve_storage_get_relative_link_path
 	(const char *active_path, const char *storage_dir) 
@@ -411,8 +412,8 @@ struct sieve_error_handler *sieve_storage_get_error_handler
 }
 
 static void sieve_storage_verror
-(struct sieve_error_handler *ehandler, const char *location ATTR_UNUSED,
-    const char *fmt, va_list args)
+(struct sieve_error_handler *ehandler, unsigned int flags ATTR_UNUSED,
+	const char *location ATTR_UNUSED, const char *fmt, va_list args)
 {
 	struct sieve_storage_ehandler *sehandler = 
 		(struct sieve_storage_ehandler *) ehandler; 
diff --git a/src/plugins/lda-sieve/lda-sieve-log.c b/src/plugins/lda-sieve/lda-sieve-log.c
index 1b12809c7c5a94ca4ae096a17447094fa5a4f7c6..482a88a90d4131955525206168d10c78a8c3e49b 100644
--- a/src/plugins/lda-sieve/lda-sieve-log.c
+++ b/src/plugins/lda-sieve/lda-sieve-log.c
@@ -33,8 +33,6 @@ static void lda_sieve_vlog
 	struct mail_deliver_context *mdctx = ehandler->mdctx;
 	string_t *str;
 
-	if ( _ehandler->log_master ) return;
-
 	str = t_str_new(256);
 	if ( mdctx->session_id != NULL)
 		str_printfa(str, "%s: ", mdctx->session_id);
@@ -50,27 +48,27 @@ static void lda_sieve_vlog
 }
 
 static void lda_sieve_log_verror
-(struct sieve_error_handler *ehandler, const char *location,
-	const char *fmt, va_list args) 
+(struct sieve_error_handler *ehandler, unsigned int flags ATTR_UNUSED,
+	const char *location, const char *fmt, va_list args) 
 {
 	lda_sieve_vlog(ehandler, i_error, location, fmt, args);
 }
 static void lda_sieve_log_vwarning
-(struct sieve_error_handler *ehandler, const char *location,
-	const char *fmt, va_list args) 
+(struct sieve_error_handler *ehandler, unsigned int flags ATTR_UNUSED,
+	const char *location, const char *fmt, va_list args) 
 {
 	lda_sieve_vlog(ehandler, i_warning, location, fmt, args);
 }
 static void lda_sieve_log_vinfo
-(struct sieve_error_handler *ehandler, const char *location,
-	const char *fmt, va_list args) 
+(struct sieve_error_handler *ehandler, unsigned int flags ATTR_UNUSED,
+	const char *location, const char *fmt, va_list args) 
 {
 	lda_sieve_vlog(ehandler, i_info, location, fmt, args);
 }
 
 static void lda_sieve_log_vdebug
-(struct sieve_error_handler *ehandler, const char *location,
-	const char *fmt, va_list args) 
+(struct sieve_error_handler *ehandler, unsigned int flags ATTR_UNUSED,
+	const char *location, const char *fmt, va_list args) 
 {
 	lda_sieve_vlog(ehandler, i_debug, location, fmt, args);
 }
diff --git a/src/plugins/lda-sieve/lda-sieve-plugin.c b/src/plugins/lda-sieve/lda-sieve-plugin.c
index 4749f3498657f57b6fe84424a0e0ad4ba3a4791c..0918e3f593607e13071dc69cd93b07359c4d8184 100644
--- a/src/plugins/lda-sieve/lda-sieve-plugin.c
+++ b/src/plugins/lda-sieve/lda-sieve-plugin.c
@@ -402,15 +402,12 @@ static int lda_sieve_singlescript_execute
 
 	if ( user_script ) {
 		ehandler = srctx->user_ehandler;
-		sieve_error_handler_copy_masterlog(ehandler, TRUE);
 	} else {
 		ehandler = srctx->master_ehandler;
 	}
 
 	ret = sieve_execute(sbin, srctx->msgdata, srctx->scriptenv, ehandler, NULL);
 
-	sieve_error_handler_copy_masterlog(ehandler, FALSE);
-
 	/* Recompile if corrupt binary */
 
 	if ( ret == SIEVE_EXEC_BIN_CORRUPT && sieve_is_loaded(sbin) ) {
@@ -429,13 +426,8 @@ static int lda_sieve_singlescript_execute
 			sieve_sys_debug
 				(svinst, "executing script from %s", sieve_get_source(sbin));
 
-		if ( user_script )
-			sieve_error_handler_copy_masterlog(ehandler, TRUE);
-
 		ret = sieve_execute(sbin, srctx->msgdata, srctx->scriptenv, ehandler, NULL);
 
-		sieve_error_handler_copy_masterlog(ehandler, FALSE);
-
 		/* Save new version */
 
 		if ( ret != SIEVE_EXEC_BIN_CORRUPT )
@@ -493,16 +485,11 @@ static int lda_sieve_multiscript_execute
 
 		/* Execute */
 
-		if ( user_script )
-			sieve_error_handler_copy_masterlog(ehandler, TRUE);
-
 		if ( debug )
 			sieve_sys_debug(svinst, "executing script from %s", sieve_get_source(sbin));
 
 		more = sieve_multiscript_run(mscript, sbin, ehandler, final);
 
-		sieve_error_handler_copy_masterlog(ehandler, FALSE);
-
 		if ( !more ) {
 			if ( sieve_multiscript_status(mscript) == SIEVE_EXEC_BIN_CORRUPT &&
 				sieve_is_loaded(sbin) ) {
@@ -519,13 +506,8 @@ static int lda_sieve_multiscript_execute
 
 				/* Execute again */
 
-				if ( user_script )
-					sieve_error_handler_copy_masterlog(ehandler, TRUE);
-
 				more = sieve_multiscript_run(mscript, sbin, ehandler, final);
 
-				sieve_error_handler_copy_masterlog(ehandler, FALSE);
-
 				/* Save new version */
 
 				if ( more && 
@@ -539,13 +521,8 @@ static int lda_sieve_multiscript_execute
 
 	/* Finish execution */
 
-	if ( user_script )
-		sieve_error_handler_copy_masterlog(ehandler, TRUE);
-
 	ret = sieve_multiscript_finish(&mscript, ehandler, NULL);
 
-	sieve_error_handler_copy_masterlog(ehandler, FALSE);
-
 	return lda_sieve_handle_exec_status(srctx, last_script, ret);
 }
 
diff --git a/src/testsuite/testsuite-log.c b/src/testsuite/testsuite-log.c
index d713d49c8967bb7a63dd3c53469be1e73d94949e..20f2c77dd9433896407c528c0cf199fe9e9f1ccb 100644
--- a/src/testsuite/testsuite-log.c
+++ b/src/testsuite/testsuite-log.c
@@ -35,8 +35,9 @@ ARRAY_DEFINE(_testsuite_log_errors, struct _testsuite_log_message);
 ARRAY_DEFINE(_testsuite_log_warnings, struct _testsuite_log_message);
 
 static void _testsuite_log_verror
-(struct sieve_error_handler *ehandler ATTR_UNUSED, const char *location,
-	const char *fmt, va_list args)
+(struct sieve_error_handler *ehandler ATTR_UNUSED,
+	unsigned int flags ATTR_UNUSED, const char *location, const char *fmt,
+	va_list args)
 {
 	pool_t pool = _testsuite_logmsg_pool;
 	struct _testsuite_log_message msg;
@@ -60,8 +61,9 @@ static void _testsuite_log_verror
 }
 
 static void _testsuite_log_main_verror
-(struct sieve_error_handler *ehandler ATTR_UNUSED, const char *location,
-	const char *fmt, va_list args)
+(struct sieve_error_handler *ehandler ATTR_UNUSED,
+	unsigned int flags ATTR_UNUSED, const char *location, const char *fmt,
+	va_list args)
 {
 	if ( location == NULL || *location == '\0' )
 		fprintf(stderr, 
@@ -72,8 +74,9 @@ static void _testsuite_log_main_verror
 }
 
 static void _testsuite_log_vwarning
-(struct sieve_error_handler *ehandler ATTR_UNUSED, const char *location,
-	const char *fmt, va_list args)
+(struct sieve_error_handler *ehandler ATTR_UNUSED,
+	unsigned int flags ATTR_UNUSED, const char *location, const char *fmt,
+	va_list args)
 {
 	pool_t pool = _testsuite_logmsg_pool;
 	struct _testsuite_log_message msg;