mirror of https://github.com/postgres/postgres
Provide log_status_format(), useful for an emit_log_hook.
Refactor so that log_line_prefix() is a thin wrapper over a new function log_status_format(), and move the implementation to the latter. Export log_status_format() so that it can be used by an emit_log_hook. Discussion: https://postgr.es/m/39c8197652f4d3050aedafae79fa5af31096505f.camel%40j-davis.com Reviewed-by: Michael Paquier, Alvaro Herrera
This commit is contained in:
parent
bf022d337e
commit
b40baa96a7
|
@ -2438,10 +2438,19 @@ process_log_prefix_padding(const char *p, int *ppadding)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Format tag info for log lines; append to the provided buffer.
|
* Format log status information using Log_line_prefix.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
log_line_prefix(StringInfo buf, ErrorData *edata)
|
log_line_prefix(StringInfo buf, ErrorData *edata)
|
||||||
|
{
|
||||||
|
log_status_format(buf, Log_line_prefix, edata);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Format log status info; append to the provided buffer.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
log_status_format(StringInfo buf, const char *format, ErrorData *edata)
|
||||||
{
|
{
|
||||||
/* static counter for line numbers */
|
/* static counter for line numbers */
|
||||||
static long log_line_number = 0;
|
static long log_line_number = 0;
|
||||||
|
@ -2465,10 +2474,10 @@ log_line_prefix(StringInfo buf, ErrorData *edata)
|
||||||
}
|
}
|
||||||
log_line_number++;
|
log_line_number++;
|
||||||
|
|
||||||
if (Log_line_prefix == NULL)
|
if (format == NULL)
|
||||||
return; /* in case guc hasn't run yet */
|
return; /* in case guc hasn't run yet */
|
||||||
|
|
||||||
for (p = Log_line_prefix; *p != '\0'; p++)
|
for (p = format; *p != '\0'; p++)
|
||||||
{
|
{
|
||||||
if (*p != '%')
|
if (*p != '%')
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
|
|
||||||
|
#include "lib/stringinfo.h"
|
||||||
|
|
||||||
/* Error level codes */
|
/* Error level codes */
|
||||||
#define DEBUG5 10 /* Debugging messages, in categories of
|
#define DEBUG5 10 /* Debugging messages, in categories of
|
||||||
* decreasing detail. */
|
* decreasing detail. */
|
||||||
|
@ -439,6 +441,8 @@ extern PGDLLIMPORT bool syslog_split_messages;
|
||||||
#define LOG_DESTINATION_JSONLOG 16
|
#define LOG_DESTINATION_JSONLOG 16
|
||||||
|
|
||||||
/* Other exported functions */
|
/* Other exported functions */
|
||||||
|
extern void log_status_format(StringInfo buf, const char *format,
|
||||||
|
ErrorData *edata);
|
||||||
extern void DebugFileOpen(void);
|
extern void DebugFileOpen(void);
|
||||||
extern char *unpack_sql_state(int sql_state);
|
extern char *unpack_sql_state(int sql_state);
|
||||||
extern bool in_error_recursion_trouble(void);
|
extern bool in_error_recursion_trouble(void);
|
||||||
|
|
Loading…
Reference in New Issue