Export log_line_prefix(); useful for emit_log_hook.

Started by Jeff Davisalmost 4 years ago6 messageshackers
Jump to latest
#1Jeff Davis
pgsql@j-davis.com

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.patchtext/x-patch; charset=UTF-8; name=0001-Export-log_line_prefix-useful-for-emit_log_hook.patchDownload+4-3
#2Michael Paquier
michael@paquier.xyz
In reply to: Jeff Davis (#1)
Re: Export log_line_prefix(); useful for emit_log_hook.

On Tue, Jun 28, 2022 at 11:52:56AM -0700, Jeff Davis wrote:

Patch attached. Some kinds of emit log hooks might find it useful to
also compute the log_line_prefix.

Have you played with anything specific that would require that? I
am fine to expose this routine, being mostly curious about what kind
of recent format implemented with the elog hook would use it.
--
Michael

#3Jeff Davis
pgsql@j-davis.com
In reply to: Michael Paquier (#2)
Re: Export log_line_prefix(); useful for emit_log_hook.

On Wed, 2022-06-29 at 10:17 +0900, Michael Paquier wrote:

On Tue, Jun 28, 2022 at 11:52:56AM -0700, Jeff Davis wrote:

Patch attached. Some kinds of emit log hooks might find it useful
to
also compute the log_line_prefix.

Have you played with anything specific that would require that? I
am fine to expose this routine, being mostly curious about what kind
of recent format implemented with the elog hook would use it.

Just a slightly different format that is directly digestible by another
system, while still preserving what the original messages in the file
would look like.

There are other ways to do it, but it's convenient. If we use, e.g.,
csv or json format, we lose the log_line_prefix and would need to
regenerate it from the individual fields.

Regards,
Jeff Davis

#4Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Jeff Davis (#1)
Re: Export log_line_prefix(); useful for emit_log_hook.

On 2022-Jun-28, Jeff Davis wrote:

Patch attached. Some kinds of emit log hooks might find it useful to
also compute the log_line_prefix.

Hmm, maybe your hypothetical book would prefer to use a different
setting for log line prefix than Log_line_prefix, so it would make sense
to pass the format string as a parameter to the function instead of
relying on the GUC global.

--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/
"Java is clearly an example of money oriented programming" (A. Stepanov)

#5Michael Paquier
michael@paquier.xyz
In reply to: Alvaro Herrera (#4)
Re: Export log_line_prefix(); useful for emit_log_hook.

On Wed, Jun 29, 2022 at 03:09:42PM +0200, Alvaro Herrera wrote:

Hmm, maybe your hypothetical book would prefer to use a different
setting for log line prefix than Log_line_prefix, so it would make sense
to pass the format string as a parameter to the function instead of
relying on the GUC global.

+1.
--
Michael
#6Jeff Davis
pgsql@j-davis.com
In reply to: Michael Paquier (#5)
Re: Export log_line_prefix(); useful for emit_log_hook.

On Mon, 2022-07-04 at 15:54 +0900, Michael Paquier wrote:

On Wed, Jun 29, 2022 at 03:09:42PM +0200, Alvaro Herrera wrote:

Hmm, maybe your hypothetical book would prefer to use a different
setting for log line prefix than Log_line_prefix, so it would make
sense
to pass the format string as a parameter to the function instead of
relying on the GUC global.

That is nicer, attached.

I also renamed the function log_status_format(), and made
log_line_prefix() a thin wrapper over that. I think that's less
confusing.

Regards,
Jeff Davis

Attachments:

v2-0001-Provide-log_status_format-useful-for-an-emit_log_hoo.patchtext/x-patch; charset=UTF-8; name*0=v2-0001-Provide-log_status_format-useful-for-an-emit_log_hoo.patc; name*1=hDownload+15-4