↑↓ select ↵ open ⌫ change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

Documentation / Extension Hooks / Logging and function calls

emit_log_hook

emit_log_hook

Hook for intercepting messages before they are sent to the server log

Reading PostgreSQL 18.

Description

Hook for intercepting messages before they are sent to the server log

Interface type
emit_log_hook_type
Header
src/include/utils/elog.h
Subsystem
Logging and function calls
Initial value
NULL (no hook installed)

C interface

typedef void (*emit_log_hook_type) (ErrorData *edata);
extern PGDLLIMPORT emit_log_hook_type emit_log_hook;

Core source comments

Hook for intercepting messages before they are sent to the server log. Note that the hook will not get called for messages that are suppressed by log_min_messages. Also note that logging hooks implemented in preload libraries will miss any log messages that are generated before the library is loaded.

Call sites

src/backend/utils/error/elog.c:1729

Core call context: src/backend/utils/error/elog.c:1723–1737

	 * The log hook has access to both the translated and original English
	 * error message text, which is passed through to allow it to be used as a
	 * message identifier. Note that the original text is not available for
	 * detail, detail_log, hint and context text elements.
	 */
	if (edata->output_to_server && emit_log_hook)
		(*emit_log_hook) (edata);

	/* Send to server log, if enabled */
	if (edata->output_to_server)
		send_message_to_server_log(edata);

	/* Send to client, if enabled */
	if (edata->output_to_client)
		send_message_to_frontend(edata);

Documentation and source

Source build
Version
18
Build
REL_18_STABLE
Source fingerprint
753057e340da8f22e57c9a409ea7a235fd6a46bd

Related entries

Back to Extension Hooks · Recorded in PostgreSQL 10 through 20; the first sample is not necessarily its introduction.