failures.c (dovecot-2.3.16) | : | failures.c (dovecot-2.3.17) | ||
---|---|---|---|---|
skipping to change at line 64 | skipping to change at line 64 | |||
static struct failure_context failure_ctx_error = { .type = LOG_TYPE_ERROR }; | static struct failure_context failure_ctx_error = { .type = LOG_TYPE_ERROR }; | |||
static int log_fd = STDERR_FILENO, log_info_fd = STDERR_FILENO, | static int log_fd = STDERR_FILENO, log_info_fd = STDERR_FILENO, | |||
log_debug_fd = STDERR_FILENO; | log_debug_fd = STDERR_FILENO; | |||
static char *log_prefix = NULL; | static char *log_prefix = NULL; | |||
static char *log_stamp_format = NULL, *log_stamp_format_suffix = NULL; | static char *log_stamp_format = NULL, *log_stamp_format_suffix = NULL; | |||
static bool failure_ignore_errors = FALSE, log_prefix_sent = FALSE; | static bool failure_ignore_errors = FALSE, log_prefix_sent = FALSE; | |||
static bool coredump_on_error = FALSE; | static bool coredump_on_error = FALSE; | |||
static void log_timestamp_add(const struct failure_context *ctx, string_t *str); | static void log_timestamp_add(const struct failure_context *ctx, string_t *str); | |||
static void log_prefix_add(const struct failure_context *ctx, string_t *str); | static void log_prefix_add(const struct failure_context *ctx, string_t *str); | |||
static void i_failure_send_option(const char *key, const char *value); | static void i_failure_send_option_forced(const char *key, const char *value); | |||
static int internal_send_split(string_t *full_str, size_t prefix_len); | static int internal_send_split(string_t *full_str, size_t prefix_len); | |||
static string_t * ATTR_FORMAT(3, 0) default_format(const struct failure_context *ctx, | static string_t * ATTR_FORMAT(3, 0) default_format(const struct failure_context *ctx, | |||
size_t *prefix_len_r ATTR_UNUS ED, | size_t *prefix_len_r ATTR_UNUS ED, | |||
const char *format, | const char *format, | |||
va_list args) | va_list args) | |||
{ | { | |||
string_t *str = t_str_new(256); | string_t *str = t_str_new(256); | |||
log_timestamp_add(ctx, str); | log_timestamp_add(ctx, str); | |||
log_prefix_add(ctx, str); | log_prefix_add(ctx, str); | |||
skipping to change at line 195 | skipping to change at line 195 | |||
{ | { | |||
string_t *str; | string_t *str; | |||
unsigned char log_type = ctx->type + 1; | unsigned char log_type = ctx->type + 1; | |||
if (ctx->log_prefix != NULL) { | if (ctx->log_prefix != NULL) { | |||
log_type |= LOG_TYPE_FLAG_DISABLE_LOG_PREFIX; | log_type |= LOG_TYPE_FLAG_DISABLE_LOG_PREFIX; | |||
if (ctx->log_prefix_type_pos != 0) | if (ctx->log_prefix_type_pos != 0) | |||
log_type |= LOG_TYPE_FLAG_PREFIX_LEN; | log_type |= LOG_TYPE_FLAG_PREFIX_LEN; | |||
} else if (!log_prefix_sent && log_prefix != NULL) { | } else if (!log_prefix_sent && log_prefix != NULL) { | |||
log_prefix_sent = TRUE; | log_prefix_sent = TRUE; | |||
i_failure_send_option("prefix", log_prefix); | i_failure_send_option_forced("prefix", log_prefix); | |||
} | } | |||
str = t_str_new(128); | str = t_str_new(128); | |||
str_printfa(str, "\001%c%s ", log_type, my_pid); | str_printfa(str, "\001%c%s ", log_type, my_pid); | |||
if ((log_type & LOG_TYPE_FLAG_PREFIX_LEN) != 0) | if ((log_type & LOG_TYPE_FLAG_PREFIX_LEN) != 0) | |||
str_printfa(str, "%u ", ctx->log_prefix_type_pos); | str_printfa(str, "%u ", ctx->log_prefix_type_pos); | |||
if (ctx->log_prefix != NULL) | if (ctx->log_prefix != NULL) | |||
str_append(str, ctx->log_prefix); | str_append(str, ctx->log_prefix); | |||
*prefix_len_r = str_len(str); | *prefix_len_r = str_len(str); | |||
skipping to change at line 723 | skipping to change at line 723 | |||
overrides these later. */ | overrides these later. */ | |||
log_info_fd = log_fd; | log_info_fd = log_fd; | |||
log_debug_fd = log_fd; | log_debug_fd = log_fd; | |||
i_set_fatal_handler(default_fatal_handler); | i_set_fatal_handler(default_fatal_handler); | |||
i_set_error_handler(default_error_handler); | i_set_error_handler(default_error_handler); | |||
i_set_info_handler(default_error_handler); | i_set_info_handler(default_error_handler); | |||
i_set_debug_handler(default_error_handler); | i_set_debug_handler(default_error_handler); | |||
} | } | |||
static void i_failure_send_option(const char *key, const char *value) | static void i_failure_send_option_forced(const char *key, const char *value) | |||
{ | { | |||
const char *str; | const char *str; | |||
if (error_handler != i_internal_error_handler) | ||||
return; | ||||
str = t_strdup_printf("\001%c%s %s=%s\n", LOG_TYPE_OPTION+1, | str = t_strdup_printf("\001%c%s %s=%s\n", LOG_TYPE_OPTION+1, | |||
my_pid, key, value); | my_pid, key, value); | |||
(void)write_full(STDERR_FILENO, str, strlen(str)); | (void)write_full(STDERR_FILENO, str, strlen(str)); | |||
} | } | |||
static void i_failure_send_option(const char *key, const char *value) | ||||
{ | ||||
if (error_handler == i_internal_error_handler) | ||||
i_failure_send_option_forced(key, value); | ||||
} | ||||
void i_set_failure_prefix(const char *prefix_fmt, ...) | void i_set_failure_prefix(const char *prefix_fmt, ...) | |||
{ | { | |||
va_list args; | va_list args; | |||
va_start(args, prefix_fmt); | va_start(args, prefix_fmt); | |||
i_free(log_prefix); | i_free(log_prefix); | |||
log_prefix = i_strdup_vprintf(prefix_fmt, args); | log_prefix = i_strdup_vprintf(prefix_fmt, args); | |||
va_end(args); | va_end(args); | |||
log_prefix_sent = FALSE; | log_prefix_sent = FALSE; | |||
End of changes. 5 change blocks. | ||||
6 lines changed or deleted | 9 lines changed or added |