diff options
| author | Michael Paquier <michael@paquier.xyz> | 2022-01-12 14:16:59 +0900 |
|---|---|---|
| committer | Michael Paquier <michael@paquier.xyz> | 2022-01-12 14:16:59 +0900 |
| commit | ac7c80758a7ad6369aefce7406f08c689144ec4b (patch) | |
| tree | 2a42b18e86912ceb5137eaf6033bf443b3a37bc9 /src/include/utils | |
| parent | 9a3d8e1886670ca3532687c5336d97965a79a084 (diff) | |
Refactor set of routines specific to elog.c
This refactors the following routines and facilities coming from
elog.c, to ease their use across multiple log destinations:
- Start timestamp, including its reset, to store when a process has been
started.
- The log timestamp, associated to an entry (the same timestamp is used
when logging across multiple destinations).
- Routine deciding if a query can be logged or not.
- The backend type names, depending on the process that logs any
information (postmaster, bgworker name or just GetBackendTypeDesc() with
a regular backend).
- Write of logs using the logging piped protocol, with the log collector
enabled.
- Error severity converted to a string.
These refactored routines will be used for some follow-up changes
to move all the csvlog logic into its own file and to potentially add
JSON as log destination, reducing the overall size of elog.c as the end
result.
Author: Michael Paquier, Sehrope Sarkuni
Reviewed-by: Nathan Bossart
Discussion: https://postgr.es/m/CAH7T-aqswBM6JWe4pDehi1uOiufqe06DJWaU5=X7dDLyqUExHg@mail.gmail.com
Diffstat (limited to 'src/include/utils')
| -rw-r--r-- | src/include/utils/elog.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/include/utils/elog.h b/src/include/utils/elog.h index 8df2799dc29..5bc38663cb3 100644 --- a/src/include/utils/elog.h +++ b/src/include/utils/elog.h @@ -442,6 +442,18 @@ extern void DebugFileOpen(void); extern char *unpack_sql_state(int sql_state); extern bool in_error_recursion_trouble(void); +/* Common functions shared across destinations */ +extern void reset_formatted_start_time(void); +extern char *get_formatted_start_time(void); +extern char *get_formatted_log_time(void); +extern const char *get_backend_type_for_log(void); +extern bool check_log_of_query(ErrorData *edata); +extern const char *error_severity(int elevel); +extern void write_pipe_chunks(char *data, int len, int dest); + +/* Destination-specific functions */ +extern void write_csvlog(ErrorData *edata); + #ifdef HAVE_SYSLOG extern void set_syslog_parameters(const char *ident, int facility); #endif |
