From: Sergey Kitov Date: Tue, 12 Jun 2018 12:56:46 +0000 (+0300) Subject: lib: Introduce abstraction for failure logging implementations. X-Git-Tag: 2.3.4~207 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=521a9dbd0ec13664b6e91c89dad9df1445b74685;p=thirdparty%2Fdovecot%2Fcore.git lib: Introduce abstraction for failure logging implementations. --- diff --git a/src/lib/failures.c b/src/lib/failures.c index e8de68a8cc..560250758a 100644 --- a/src/lib/failures.c +++ b/src/lib/failures.c @@ -52,6 +52,26 @@ static char *log_stamp_format = NULL, *log_stamp_format_suffix = NULL; static bool failure_ignore_errors = FALSE, log_prefix_sent = FALSE; static bool coredump_on_error = FALSE; +typedef int (*failure_write_to_file_t)(enum log_type type, string_t *data, size_t prefix_len); +typedef string_t *(*failure_format_str_t)(const struct failure_context *ctx, + size_t *prefix_len_r, const char *format, + va_list args); +typedef void (*failure_on_handler_failure_t)(const struct failure_context *ctx); +typedef void (*failure_post_handler_t)(const struct failure_context *ctx); + + +struct failure_handler_vfuncs { + failure_write_to_file_t write; + failure_format_str_t format; + failure_on_handler_failure_t on_handler_failure; + failure_post_handler_t post_handler; +}; + +struct failure_handler_config { + int fatal_err_reset; + struct failure_handler_vfuncs *v; +}; + static void ATTR_FORMAT(2, 0) i_internal_error_handler(const struct failure_context *ctx, const char *format, va_list args);