pg.ddx.io pgsql-hackers@postgresql.org mailing list archive
help / color / mirror / Atom feed From: Jeff Davis <pgsql@j-davis.com>
To: pgsql-hackers@postgresql.org
Subject: Export log_line_prefix(); useful for emit_log_hook.
Date: Tue, 28 Jun 2022 11:52:56 -0700
Message-ID: <39c8197652f4d3050aedafae79fa5af31096505f.camel@j-davis.com> (raw )
Patch attached. Some kinds of emit log hooks might find it useful to
also compute the log_line_prefix.
Regards,
Jeff Davis
Attachments:
0001-Export-log_line_prefix-useful-for-emit_log_hook.patch (text/x-patch, 2.0K) download
From c3d4f14602c043918b8b6dab88a976dac1923208 Mon Sep 17 00:00:00 2001
From: Jeff Davis <jeff@j-davis.com>
Date: Tue, 28 Jun 2022 11:39:33 -0700
Subject: [PATCH] Export log_line_prefix(); useful for emit_log_hook.
---
src/backend/utils/error/elog.c | 3 +--
src/include/utils/elog.h | 3 +++
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 55ee5423afb..4cd6a713ebb 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -176,7 +176,6 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip);
static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str);
static void write_console(const char *line, int len);
static const char *process_log_prefix_padding(const char *p, int *padding);
-static void log_line_prefix(StringInfo buf, ErrorData *edata);
static void send_message_to_server_log(ErrorData *edata);
static void send_message_to_frontend(ErrorData *edata);
static void append_with_tabs(StringInfo buf, const char *str);
@@ -2441,7 +2440,7 @@ process_log_prefix_padding(const char *p, int *ppadding)
/*
* Format tag info for log lines; append to the provided buffer.
*/
-static void
+void
log_line_prefix(StringInfo buf, ErrorData *edata)
{
/* static counter for line numbers */
diff --git a/src/include/utils/elog.h b/src/include/utils/elog.h
index f5c6cd904de..71aaf40614c 100644
--- a/src/include/utils/elog.h
+++ b/src/include/utils/elog.h
@@ -16,6 +16,8 @@
#include <setjmp.h>
+#include "lib/stringinfo.h"
+
/* Error level codes */
#define DEBUG5 10 /* Debugging messages, in categories of
* decreasing detail. */
@@ -439,6 +441,7 @@ extern PGDLLIMPORT bool syslog_split_messages;
#define LOG_DESTINATION_JSONLOG 16
/* Other exported functions */
+extern void log_line_prefix(StringInfo buf, ErrorData *edata);
extern void DebugFileOpen(void);
extern char *unpack_sql_state(int sql_state);
extern bool in_error_recursion_trouble(void);
--
2.17.1
view thread (6+ messages) latest in thread
Message-ID: <39c8197652f4d3050aedafae79fa5af31096505f.camel@j-davis.com>
Permalink: ../39c8197652f4d3050aedafae79fa5af31096505f.camel@j-davis.com/
Also on: postgresql.org/message-id/39c8197652f4d3050aedafae79fa5af31096505f.camel@j-davis.com
copy link · copy postgr.es · copy git am
reply Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: pgsql@j-davis.com
Subject: Re: Export log_line_prefix(); useful for emit_log_hook.
In-Reply-To: <39c8197652f4d3050aedafae79fa5af31096505f.camel@j-davis.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox