{"Entry":{"collection":"hook","key":"emit_log_hook","name":"emit_log_hook","aliases":[],"metadata":{"aliases":[],"category":"Logging and function calls","content_hash":"d7872f897b49960c2b5cee5826b987e2dabda39df3d919b29cf6551aa2a3b9ee","derived_content_hash":"51009d1d0f3c541d0ee5df0c3246fd44520fd2d34c944d637331a1af89694022","imported_at":"2026-09-27T17:57:58.841025+08:00","name":"emit_log_hook","name_zh":"emit_log_hook","repair_provenance":{"original_source_revision":"","receipt_sha256":"c557e612fcbf977de2bbd217a12560f50720b4da1131b4b4fcadb89e5250c577","repair":"wiki-repair-20261023"},"slug":"emit_log_hook","source_rev":"wiki-repair-20261023:400895f5b6ad836ace2dfd6db97de10c6320c8ff5204bd6e45bbe07c8510cf0a","summary":"Hook for intercepting messages before they are sent to the server log"}},"Definition":{"Collection":"hook","Key":"emit_log_hook","SourceDatabase":"center","Version":"18","SourceTable":"hook","SourceKey":"emit_log_hook","SourceRevision":"753057e340da8f22e57c9a409ea7a235fd6a46bd","Facts":{"description":["Hook for intercepting messages before they are sent to the server log"],"description_zh":"在消息写入服务器日志之前拦截消息的钩子。","description_zh_html":"\u003cp\u003e在消息写入服务器日志之前拦截消息的钩子。\u003c/p\u003e\u003cp\u003e以下中文为本站依据所列 PostgreSQL 源码注释编译的说明。\u003c/p\u003e\u003ch3\u003e接口声明\u003c/h3\u003e\u003cpre\u003etypedef void (*emit_log_hook_type) (ErrorData *edata);\nextern PGDLLIMPORT emit_log_hook_type emit_log_hook;\u003c/pre\u003e\u003ch3\u003e源码说明\u003c/h3\u003e\u003cp\u003e在消息写入服务器日志之前拦截消息。被 log_min_messages 抑制的消息不会调用此钩子；预加载库中的日志钩子也无法捕获该库加载之前产生的日志消息。\u003c/p\u003e\u003ch3\u003e调用位置\u003c/h3\u003e\u003cul\u003e\u003cli\u003e\u003ccode\u003esrc/backend/utils/error/elog.c:1729\u003c/code\u003e\u003c/li\u003e\u003c/ul\u003e\u003ch3\u003e核心调用上下文：src/backend/utils/error/elog.c:1723–1737\u003c/h3\u003e\u003cpre\u003e\t * The log hook has access to both the translated and original English\n\t * error message text, which is passed through to allow it to be used as a\n\t * message identifier. Note that the original text is not available for\n\t * detail, detail_log, hint and context text elements.\n\t */\n\tif (edata-\u0026gt;output_to_server \u0026amp;\u0026amp; emit_log_hook)\n\t\t(*emit_log_hook) (edata);\n\n\t/* Send to server log, if enabled */\n\tif (edata-\u0026gt;output_to_server)\n\t\tsend_message_to_server_log(edata);\n\n\t/* Send to client, if enabled */\n\tif (edata-\u0026gt;output_to_client)\n\t\tsend_message_to_frontend(edata);\u003c/pre\u003e","facts":[{"label":"Interface type","value":"emit_log_hook_type"},{"label":"Header","value":"src/include/utils/elog.h"},{"label":"Subsystem","value":"Logging and function calls"},{"label":"Initial value","value":"NULL (no hook installed)"}],"related":[],"release":{"channel":"stable","label":"18","major":"18","ref":"REL_18_STABLE","revision":"753057e340da8f22e57c9a409ea7a235fd6a46bd"},"sections":[{"paragraphs":["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."],"title":"Core source comments"},{"paragraphs":["src/backend/utils/error/elog.c:1729"],"title":"Call sites"},{"code":"\t * The log hook has access to both the translated and original English\n\t * error message text, which is passed through to allow it to be used as a\n\t * message identifier. Note that the original text is not available for\n\t * detail, detail_log, hint and context text elements.\n\t */\n\tif (edata-\u003eoutput_to_server \u0026\u0026 emit_log_hook)\n\t\t(*emit_log_hook) (edata);\n\n\t/* Send to server log, if enabled */\n\tif (edata-\u003eoutput_to_server)\n\t\tsend_message_to_server_log(edata);\n\n\t/* Send to client, if enabled */\n\tif (edata-\u003eoutput_to_client)\n\t\tsend_message_to_frontend(edata);","paragraphs":[],"title":"Core call context: src/backend/utils/error/elog.c:1723–1737"}],"signature":"typedef void (*emit_log_hook_type) (ErrorData *edata);\nextern PGDLLIMPORT emit_log_hook_type emit_log_hook;","sources":[{"label":"Interface declaration","path":"src/include/utils/elog.h","sha256":"3485d4a046bd4fcc5f5887f7ea9badc3f430f1bd67c4b103d3e3a6fa54b38bc0","url":"https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/include/utils/elog.h#L477"},{"label":"Core definition","path":"src/backend/utils/error/elog.c","sha256":"766d30a426ba1d9597657bd46fb890da3e37e4ae53a83d1245bf082ed9433c33","url":"https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/utils/error/elog.c#L106"},{"label":"Call sites","path":"src/backend/utils/error/elog.c","sha256":"766d30a426ba1d9597657bd46fb890da3e37e4ae53a83d1245bf082ed9433c33","url":"https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/utils/error/elog.c#L1729"}],"translation_provenance":{"inputs":[{"label":"Interface declaration","path":"src/include/utils/elog.h","sha256":"3485d4a046bd4fcc5f5887f7ea9badc3f430f1bd67c4b103d3e3a6fa54b38bc0","url":"https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/include/utils/elog.h#L477"},{"label":"Core definition","path":"src/backend/utils/error/elog.c","sha256":"766d30a426ba1d9597657bd46fb890da3e37e4ae53a83d1245bf082ed9433c33","url":"https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/utils/error/elog.c#L106"},{"label":"Call sites","path":"src/backend/utils/error/elog.c","sha256":"766d30a426ba1d9597657bd46fb890da3e37e4ae53a83d1245bf082ed9433c33","url":"https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/utils/error/elog.c#L1729"}],"kind":"authored-source-translation","locale":"zh-Hans","source_revision":"753057e340da8f22e57c9a409ea7a235fd6a46bd","translated_source_sha256":"4c5c4d5deaf95fa85755eb04e4f9f8de006b542a97528f64bcbfac597206d6f0","version":"18"},"zh_from":"authored-source-translation"},"ManualEvidence":{"release":{"channel":"stable","label":"18","major":"18","ref":"REL_18_STABLE","revision":"753057e340da8f22e57c9a409ea7a235fd6a46bd"},"sources":[{"label":"Interface declaration","path":"src/include/utils/elog.h","sha256":"3485d4a046bd4fcc5f5887f7ea9badc3f430f1bd67c4b103d3e3a6fa54b38bc0","url":"https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/include/utils/elog.h#L477"},{"label":"Core definition","path":"src/backend/utils/error/elog.c","sha256":"766d30a426ba1d9597657bd46fb890da3e37e4ae53a83d1245bf082ed9433c33","url":"https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/utils/error/elog.c#L106"},{"label":"Call sites","path":"src/backend/utils/error/elog.c","sha256":"766d30a426ba1d9597657bd46fb890da3e37e4ae53a83d1245bf082ed9433c33","url":"https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/utils/error/elog.c#L1729"}]},"MeasuredEvidence":{}},"Text":{"Collection":"hook","Key":"emit_log_hook","SourceDatabase":"center","Version":"18","Locale":"en","Title":"emit_log_hook","Summary":"Hook for intercepting messages before they are sent to the server log","BodyHTML":"\u003cp\u003eHook for intercepting messages before they are sent to the server log\u003c/p\u003e","SourceRevision":"753057e340da8f22e57c9a409ea7a235fd6a46bd","ContentHash":"3fd7e0cd99adc626388f4d9faa05d0dd58e51f0707951443fa03d3a3f2cda520","Payload":{"description":["Hook for intercepting messages before they are sent to the server log"],"related":[],"sections":[{"paragraphs":["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."],"title":"Core source comments"},{"paragraphs":["src/backend/utils/error/elog.c:1729"],"title":"Call sites"},{"code":"\t * The log hook has access to both the translated and original English\n\t * error message text, which is passed through to allow it to be used as a\n\t * message identifier. Note that the original text is not available for\n\t * detail, detail_log, hint and context text elements.\n\t */\n\tif (edata-\u003eoutput_to_server \u0026\u0026 emit_log_hook)\n\t\t(*emit_log_hook) (edata);\n\n\t/* Send to server log, if enabled */\n\tif (edata-\u003eoutput_to_server)\n\t\tsend_message_to_server_log(edata);\n\n\t/* Send to client, if enabled */\n\tif (edata-\u003eoutput_to_client)\n\t\tsend_message_to_frontend(edata);","paragraphs":[],"title":"Core call context: src/backend/utils/error/elog.c:1723–1737"}]}},"RequestedLocale":"en","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
