{"Entry":{"collection":"hook","key":"emit_log_hook","name":"emit_log_hook","aliases":[],"metadata":{"aliases":[],"category":"Logging and function calls","content_hash":"d7872f897b49960c2b5cee5826b987e2dabda39df3d919b29cf6551aa2a3b9ee","imported_at":"2026-09-27T17:57:58.841025+08:00","name":"emit_log_hook","name_zh":"emit_log_hook","slug":"emit_log_hook","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"],"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"}]},"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":"zh-Hans","Fallback":true,"Versions":["10","11","12","13","14","15","16","17","18","19","20"],"Locales":["en"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
