On 01/17/2012 07:35 PM, Marti Raudsepp wrote: > Here's my review for the "logging hooks" patch queued for the 2012-01 > CommitFest by Martin Pihlak. >
Thanks for reviewing! > There's a minor whitespace problem. When declaring variables, and the > data type is longer than 12 characters, just use 1 single space > character to delimit the variable name, instead of tab: > Fixed both in .h and .c > I see that other hooks are declared with PGDLLIMPORT. I presume that > this is necessary on Windows: > extern PGDLLIMPORT emit_log_hook_type emit_log_hook; Indeed, fixed now. > I think the hook warrants a comment that, whether the messages will be > seen, depends on the log_min_messages setting. > Comment added. regards, Martin
*** a/src/backend/utils/error/elog.c --- b/src/backend/utils/error/elog.c *************** *** 136,141 **** static int errordata_stack_depth = -1; /* index of topmost active frame */ --- 136,148 ---- static int recursion_depth = 0; /* to detect actual recursion */ + /* + * Hook for intercepting log messages. Note that the hook does not get + * called for messages that are supressed by GUC settings such as + * log_min_messages. + */ + emit_log_hook_type emit_log_hook = NULL; + /* buffers for formatted timestamps that might be used by both * log_line_prefix and csv logs. */ *************** *** 1276,1281 **** EmitErrorReport(void) --- 1283,1291 ---- CHECK_STACK_DEPTH(); oldcontext = MemoryContextSwitchTo(ErrorContext); + if (emit_log_hook) + emit_log_hook(edata); + /* Send to server log, if enabled */ if (edata->output_to_server) send_message_to_server_log(edata); *** a/src/include/utils/elog.h --- b/src/include/utils/elog.h *************** *** 327,332 **** typedef struct ErrorData --- 327,334 ---- int saved_errno; /* errno at entry */ } ErrorData; + typedef void (*emit_log_hook_type)(ErrorData *edata); + extern void EmitErrorReport(void); extern ErrorData *CopyErrorData(void); extern void FreeErrorData(ErrorData *edata); *************** *** 347,352 **** typedef enum --- 349,355 ---- extern int Log_error_verbosity; extern char *Log_line_prefix; extern int Log_destination; + extern PGDLLIMPORT emit_log_hook_type emit_log_hook; /* Log destination bitmap */ #define LOG_DESTINATION_STDERR 1
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers