postgresCSVNames returns the names of fields in the CSV logs for version.
(version int32)
| 99 | |
| 100 | // postgresCSVNames returns the names of fields in the CSV logs for version. |
| 101 | func postgresCSVNames(version int32) string { |
| 102 | // JSON is the preferred format, so use those names. |
| 103 | // https://www.postgresql.org/docs/current/runtime-config-logging.html#RUNTIME-CONFIG-LOGGING-JSONLOG |
| 104 | |
| 105 | // https://www.postgresql.org/docs/8.3/runtime-config-logging.html#RUNTIME-CONFIG-LOGGING-CSVLOG |
| 106 | names := `timestamp,user,dbname,pid` + |
| 107 | `,connection_from` + // NOTE: this contains the JSON "remote_host" and "remote_port" values |
| 108 | `,session_id,line_num,ps,session_start,vxid,txid` + |
| 109 | `,error_severity,state_code,message,detail,hint` + |
| 110 | `,internal_query,internal_position,context,statement,cursor_position` + |
| 111 | `,location` // NOTE: this contains the JSON "func_name", "file_name", and "file_line_num" values |
| 112 | |
| 113 | // https://www.postgresql.org/docs/9.0/runtime-config-logging.html#RUNTIME-CONFIG-LOGGING-CSVLOG |
| 114 | if version >= 9 { |
| 115 | names += `,application_name` |
| 116 | } |
| 117 | |
| 118 | // https://www.postgresql.org/docs/13/runtime-config-logging.html#RUNTIME-CONFIG-LOGGING-CSVLOG |
| 119 | if version >= 13 { |
| 120 | names += `,backend_type` |
| 121 | } |
| 122 | |
| 123 | // https://www.postgresql.org/docs/14/runtime-config-logging.html#RUNTIME-CONFIG-LOGGING-CSVLOG |
| 124 | if version >= 14 { |
| 125 | names += `,leader_pid,query_id` |
| 126 | } |
| 127 | |
| 128 | return names |
| 129 | } |
| 130 | |
| 131 | func EnablePostgresLogging( |
| 132 | ctx context.Context, |
no outgoing calls
no test coverage detected