diff options
author | Andrew Dunstan <andrew@dunslane.net> | 2018-07-31 08:03:57 -0400 |
---|---|---|
committer | Andrew Dunstan <andrew@dunslane.net> | 2018-07-31 08:03:57 -0400 |
commit | 2d36a5e9dab6eda817b3d72a2d0f42c3d0cd922c (patch) | |
tree | 91220085ad3bc2a1caf7b0f245bb6706635a4013 /contrib/auto_explain/auto_explain.c | |
parent | 6574f19127ea539408267c1891ccc12ca5ebeca2 (diff) | |
download | postgresql-2d36a5e9dab6eda817b3d72a2d0f42c3d0cd922c.tar.gz postgresql-2d36a5e9dab6eda817b3d72a2d0f42c3d0cd922c.zip |
Provide a log_level setting for auto_explain
Up to now the log level has been hardcoded at LOG. A new
auto_explain.log_level setting allows that to be modified.
Discussion: https://postgr.es/m/CAPPfruyZh+snR2AdmutrA0B_caj=yWZkLqxUTZYNjJCaQ_wKQg@mail.gmail.com
Tom Dunstan and Andrew Dunstan
Reviewed by Daniel Gustafsson
Diffstat (limited to 'contrib/auto_explain/auto_explain.c')
-rw-r--r-- | contrib/auto_explain/auto_explain.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/contrib/auto_explain/auto_explain.c b/contrib/auto_explain/auto_explain.c index ea4f957cfa0..76f293cbf4a 100644 --- a/contrib/auto_explain/auto_explain.c +++ b/contrib/auto_explain/auto_explain.c @@ -28,6 +28,7 @@ static bool auto_explain_log_buffers = false; static bool auto_explain_log_triggers = false; static bool auto_explain_log_timing = true; static int auto_explain_log_format = EXPLAIN_FORMAT_TEXT; +static int auto_explain_log_level = LOG; static bool auto_explain_log_nested_statements = false; static double auto_explain_sample_rate = 1; @@ -39,6 +40,20 @@ static const struct config_enum_entry format_options[] = { {NULL, 0, false} }; +static const struct config_enum_entry loglevel_options[] = { + {"debug5", DEBUG5, false}, + {"debug4", DEBUG4, false}, + {"debug3", DEBUG3, false}, + {"debug2", DEBUG2, false}, + {"debug1", DEBUG1, false}, + {"debug", DEBUG2, true}, + {"info", INFO, false}, + {"notice", NOTICE, false}, + {"warning", WARNING, false}, + {"log", LOG, false}, + {NULL, 0, false} +}; + /* Current nesting depth of ExecutorRun calls */ static int nesting_level = 0; @@ -141,6 +156,18 @@ _PG_init(void) NULL, NULL); + DefineCustomEnumVariable("auto_explain.log_level", + "Log level for the plan.", + NULL, + &auto_explain_log_level, + LOG, + loglevel_options, + PGC_SUSET, + 0, + NULL, + NULL, + NULL); + DefineCustomBoolVariable("auto_explain.log_nested_statements", "Log nested statements.", NULL, @@ -353,7 +380,7 @@ explain_ExecutorEnd(QueryDesc *queryDesc) * reported. This isn't ideal but trying to do it here would * often result in duplication. */ - ereport(LOG, + ereport(auto_explain_log_level, (errmsg("duration: %.3f ms plan:\n%s", msec, es->str->data), errhidestmt(true))); |