diff --git a/doc/CONFIGURATION.md b/doc/CONFIGURATION.md index 0907a6e3..eaad2ef8 100644 --- a/doc/CONFIGURATION.md +++ b/doc/CONFIGURATION.md @@ -51,7 +51,7 @@ The available keys and their accepted values are reported in the table below. | metrics_cache_max_size | 256k | String | No | The maximum amount of data to keep in cache when serving Prometheus responses. Changes require restart. This parameter determines the size of memory allocated for the cache even if `metrics_cache_max_age` or `metrics` are disabled. Its value, however, is taken into account only if `metrics_cache_max_age` is set to a non-zero value. Supports suffixes: 'B' (bytes), the default if omitted, 'K' or 'KB' (kilobytes), 'M' or 'MB' (megabytes), 'G' or 'GB' (gigabytes).| | management | 0 | Int | No | The remote management port (disable = 0) | | log_type | console | String | No | The logging type (console, file, syslog) | -| log_level | info | String | No | The logging level, any of the (case insensitive) strings `FATAL`, `ERROR`, `WARN`, `INFO` and `DEBUG` (that can be more specific as `DEBUG1` thru `DEBUG5`). Debug level greater than 5 will be set to `DEBUG5`. Not recognized values will make the log_level be `INFO` | +| log_level | info | String | No | The logging level, any of the (case insensitive) strings `FATAL`, `ERROR`, `WARN`, `INFO`, `DEBUG` and `TRACE`. The `DEBUG` keyword can be more specific such as `DEBUG1` up to `DEBUG5`; higher numbers mean higher verbosity. Debug level greater than 5 will be set to `DEBUG5`, while levels lower than 1 will be set to `DEBUG1`, and the application will raise a warning about the ignored value. The word `TRACE` is a synonim for `DEBUG5`. Not recognized values will make the log_level be `INFO` | | log_path | pgagroal.log | String | No | The log file location. Can be a strftime(3) compatible string. | | log_rotation_age | 0 | String | No | The age that will trigger a log file rotation. If expressed as a positive number, is managed as seconds. Supports suffixes: 'S' (seconds, the default), 'M' (minutes), 'H' (hours), 'D' (days), 'W' (weeks). A value of `0` disables. | | log_rotation_size | 0 | String | No | The size of the log file that will trigger a log rotation. Supports suffixes: 'B' (bytes), the default if omitted, 'K' or 'KB' (kilobytes), 'M' or 'MB' (megabytes), 'G' or 'GB' (gigabytes). A value of `0` (with or without suffix) disables. | diff --git a/src/libpgagroal/configuration.c b/src/libpgagroal/configuration.c index 1d507c23..939952e1 100644 --- a/src/libpgagroal/configuration.c +++ b/src/libpgagroal/configuration.c @@ -2246,6 +2246,12 @@ as_logging_level(char* str) free(debug_value); } + if (debug_level < 1 || debug_level > 5) + { + warnx("Log level debug configuration %d not understood: %s - resetting to none", debug_level, str); + debug_level = 1; + } + if (debug_level <= 1) { return PGAGROAL_LOGGING_LEVEL_DEBUG1; @@ -2288,6 +2294,12 @@ as_logging_level(char* str) return PGAGROAL_LOGGING_LEVEL_FATAL; } + // "trace" is a synonim for "debug5" + if (!strcasecmp(str, "trace")) + { + return PGAGROAL_LOGGING_LEVEL_DEBUG5; + } + return PGAGROAL_LOGGING_LEVEL_INFO; }