Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli) created pg setting for log min error statements #2992

Merged
merged 1 commit into from
Sep 20, 2024

Conversation

brahyt-sf
Copy link
Contributor

@brahyt-sf brahyt-sf commented Aug 26, 2024

No option

🕙[ 13:15:59 ] ➜ bin/run pg:settings:log-min-error-statement postgresql-dbright-crystalline-65397 -a brahyt-dev

log-min-error-statement is set to error for postgresql-dbright-crystalline-65397.
Logs all ERROR, LOG, FATAL, and PANIC level messages. (Default)

set panic

🕙[ 13:16:06 ] ➜ bin/run pg:settings:log-min-error-statement postgresql-dbright-crystalline-65397 panic -a brahyt-dev

log-min-error-statement has been set to panic for postgresql-dbright-crystalline-65397.
Logs only PANIC level messages.
----psql----
dfmiscmbm6bodf=> select 1/0;
ERROR:  division by zero
dfmiscmbm6bodf=> select 1/0;
ERROR:  division by zero
dfmiscmbm6bodf=> select 1/0;
ERROR:  division by zero
----psql----

----heroku logs----
2024-08-26T20:18:43.000000+00:00 app[postgres.2487360]: [DBRIGHT_WHITE] [65-1]  sql_error_code = 22012 time_ms = "2024-08-26 20:18:43.325 UTC" pid="2539221" proc_start_time="2024-08-26 20:14:17 UTC" session_id="66cce219.26bed5" vtid="5/4552982" tid="0" log_line="21" database="dfmiscmbm6bodf" connection_source="13.110.54.12(17504)" user="u9ugv49trmjt9a" application_name="psql" ERROR:  division by zero
2024-08-26T20:18:43.000000+00:00 app[postgres.2487360]: [DBRIGHT_WHITE] [66-1]  sql_error_code = 22012 time_ms = "2024-08-26 20:18:43.598 UTC" pid="2539221" proc_start_time="2024-08-26 20:14:17 UTC" session_id="66cce219.26bed5" vtid="5/4552983" tid="0" log_line="22" database="dfmiscmbm6bodf" connection_source="13.110.54.12(17504)" user="u9ugv49trmjt9a" application_name="psql" ERROR:  division by zero
2024-08-26T20:18:43.000000+00:00 app[postgres.2487360]: [DBRIGHT_WHITE] [67-1]  sql_error_code = 22012 time_ms = "2024-08-26 20:18:43.841 UTC" pid="2539221" proc_start_time="2024-08-26 20:14:17 UTC" session_id="66cce219.26bed5" vtid="5/4552984" tid="0" log_line="23" database="dfmiscmbm6bodf" connection_source="13.110.54.12(17504)" user="u9ugv49trmjt9a" application_name="psql" ERROR:  division by zero
----heroku logs----

set error

🕙[ 13:18:12 ] ➜ bin/run pg:settings:log-min-error-statement postgresql-dbright-crystalline-65397 error -a brahyt-dev

log-min-error-statement has been set to error for postgresql-dbright-crystalline-65397.
Logs all ERROR, LOG, FATAL, and PANIC level messages. (Default)

----psql----
dfmiscmbm6bodf=> select 1/0;
ERROR:  division by zero
dfmiscmbm6bodf=> select 1/0;
ERROR:  division by zero
dfmiscmbm6bodf=> select 1/0;
ERROR:  division by zero
----

----heroku logs----
2024-08-26T20:20:32.000000+00:00 app[postgres.2487360]: [DBRIGHT_WHITE] [73-1]  sql_error_code = 22012 time_ms = "2024-08-26 20:20:32.224 UTC" pid="2539221" proc_start_time="2024-08-26 20:14:17 UTC" session_id="66cce219.26bed5" vtid="5/4552990" tid="0" log_line="30" database="dfmiscmbm6bodf" connection_source="13.110.54.12(17504)" user="u9ugv49trmjt9a" application_name="psql" ERROR:  division by zero
2024-08-26T20:20:32.000000+00:00 app[postgres.2487360]: [DBRIGHT_WHITE] [73-2]  sql_error_code = 22012 time_ms = "2024-08-26 20:20:32.224 UTC" pid="2539221" proc_start_time="2024-08-26 20:14:17 UTC" session_id="66cce219.26bed5" vtid="5/4552990" tid="0" log_line="31" database="dfmiscmbm6bodf" connection_source="13.110.54.12(17504)" user="u9ugv49trmjt9a" application_name="psql" STATEMENT:  select 1/0;
2024-08-26T20:20:32.000000+00:00 app[postgres.2487360]: [DBRIGHT_WHITE] [74-1]  sql_error_code = 22012 time_ms = "2024-08-26 20:20:32.591 UTC" pid="2539221" proc_start_time="2024-08-26 20:14:17 UTC" session_id="66cce219.26bed5" vtid="5/4552991" tid="0" log_line="32" database="dfmiscmbm6bodf" connection_source="13.110.54.12(17504)" user="u9ugv49trmjt9a" application_name="psql" ERROR:  division by zero
2024-08-26T20:20:32.000000+00:00 app[postgres.2487360]: [DBRIGHT_WHITE] [74-2]  sql_error_code = 22012 time_ms = "2024-08-26 20:20:32.591 UTC" pid="2539221" proc_start_time="2024-08-26 20:14:17 UTC" session_id="66cce219.26bed5" vtid="5/4552991" tid="0" log_line="33" database="dfmiscmbm6bodf" connection_source="13.110.54.12(17504)" user="u9ugv49trmjt9a" application_name="psql" STATEMENT:  select 1/0;
2024-08-26T20:20:32.000000+00:00 app[postgres.2487360]: [DBRIGHT_WHITE] [75-1]  sql_error_code = 22012 time_ms = "2024-08-26 20:20:32.990 UTC" pid="2539221" proc_start_time="2024-08-26 20:14:17 UTC" session_id="66cce219.26bed5" vtid="5/4552992" tid="0" log_line="34" database="dfmiscmbm6bodf" connection_source="13.110.54.12(17504)" user="u9ugv49trmjt9a" application_name="psql" ERROR:  division by zero
2024-08-26T20:20:32.000000+00:00 app[postgres.2487360]: [DBRIGHT_WHITE] [75-2]  sql_error_code = 22012 time_ms = "2024-08-26 20:20:32.990 UTC" pid="2539221" proc_start_time="2024-08-26 20:14:17 UTC" session_id="66cce219.26bed5" vtid="5/4552992" tid="0" log_line="35" database="dfmiscmbm6bodf" connection_source="13.110.54.12(17504)" user="u9ugv49trmjt9a" application_name="psql" STATEMENT:  select 1/0;
----heroku logs----

help

🕙[ 13:18:02 ] ❯ bin/run pg:settings:log-min-error-statement postgresql-dbright-crystalline-65397 -h -a brahyt-dev

log_min_error_statement controls the logging of SQL statements that cause an error of at least the specified severity level.

USAGE
  $ heroku pg:settings:log-min-error-statement [DATABASE] [VALUE] -a <value> [-r <value>]

FLAGS
  -a, --app=<value>     (required) app to run command against
  -r, --remote=<value>  git remote of app to use

DESCRIPTION
  log_min_error_statement controls the logging of SQL statements that cause an error of at least the specified severity level.
  This setting is useful to prevent logging SQL queries that might contain sensitive information.
  The valid values for log_min_error_statement are: error, log, fatal and panic.

@brahyt-sf brahyt-sf force-pushed the create-pg-setting-log-min-error-statement branch from aff202c to fdb3a11 Compare August 26, 2024 20:24
@brahyt-sf brahyt-sf force-pushed the create-pg-setting-log-min-error-statement branch from fdb3a11 to 2b95d9d Compare August 28, 2024 18:32
@brahyt-sf brahyt-sf marked this pull request as ready for review August 28, 2024 18:34
@brahyt-sf brahyt-sf requested a review from a team as a code owner August 28, 2024 18:34
@brahyt-sf brahyt-sf force-pushed the create-pg-setting-log-min-error-statement branch from 2b95d9d to f7e5928 Compare September 12, 2024 20:41
Copy link
Contributor

@sbosio sbosio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@sbosio sbosio merged commit 0e6afcc into main Sep 20, 2024
8 checks passed
@sbosio sbosio deleted the create-pg-setting-log-min-error-statement branch September 20, 2024 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants