diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index f33729513a..91d20214e4 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -177,7 +177,6 @@ static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *st static void write_console(const char *line, int len); static void setup_formatted_log_time(void); static void setup_formatted_start_time(void); -static const char *process_log_prefix_padding(const char *p, int *padding); static void log_line_prefix(StringInfo buf, ErrorData *edata); static void write_csvlog(ErrorData *edata); static void send_message_to_server_log(ErrorData *edata); @@ -2339,14 +2338,20 @@ setup_formatted_start_time(void) } /* - * process_log_prefix_padding --- helper function for processing the format - * string in log_line_prefix + * process_padding --- helper function for processing the format string * + * This converts initial part of the string + * and returns the first non-numeric character. + * The result of the conversion will be stored to the second argument. + * + * This function is similar to executing strtol() and isdigit(), + * but this is not affected by any locale settings. + * Note: This function returns NULL if it finds something which * it deems invalid in the format string. */ -static const char * -process_log_prefix_padding(const char *p, int *ppadding) +const char * +parse_padding(const char *p, int *ppadding) { int paddingsign = 1; int padding = 0; @@ -2427,7 +2432,7 @@ log_line_prefix(StringInfo buf, ErrorData *edata) /* * Process any formatting which may exist after the '%'. Note that - * process_log_prefix_padding moves p past the padding number if it + * parse_padding moves p past the padding number if it * exists. * * Note: Since only '-', '0' to '9' are valid formatting characters we @@ -2441,7 +2446,7 @@ log_line_prefix(StringInfo buf, ErrorData *edata) */ if (*p > '9') padding = 0; - else if ((p = process_log_prefix_padding(p, &padding)) == NULL) + else if ((p = parse_padding(p, &padding)) == NULL) break; /* process the option */ diff --git a/src/include/utils/elog.h b/src/include/utils/elog.h index f53607e12e..6e95147fb1 100644 --- a/src/include/utils/elog.h +++ b/src/include/utils/elog.h @@ -453,4 +453,7 @@ extern void set_syslog_parameters(const char *ident, int facility); */ extern void write_stderr(const char *fmt,...) pg_attribute_printf(1, 2); +/* support function for parsing format-strings */ +extern const char *parse_padding(const char *p, int *ppadding); + #endif /* ELOG_H */