feat: allow any case for logLevel (#444)
This commit is contained in:
parent
720c372be0
commit
4f99d88c0a
10
README.md
10
README.md
|
@ -54,7 +54,7 @@ For example, to configure `--log-level`, use `CODEX_LOG_LEVEL` as the environmen
|
||||||
A [TOML](https://toml.io/en/) configuration file can also be used to set configuration values. Configuration option names and corresponding values are placed in the file, separated by `=`. Configuration option names can be obtained from the `codex --help` command, and should not include the `--` prefix. For example, a node's log level (`--log-level`) can be configured using TOML as follows:
|
A [TOML](https://toml.io/en/) configuration file can also be used to set configuration values. Configuration option names and corresponding values are placed in the file, separated by `=`. Configuration option names can be obtained from the `codex --help` command, and should not include the `--` prefix. For example, a node's log level (`--log-level`) can be configured using TOML as follows:
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
log-level = "TRACE"
|
log-level = "trace"
|
||||||
```
|
```
|
||||||
|
|
||||||
The Codex node can then read the configuration from this file using the `--config-file` CLI parameter, like `codex --config-file=/path/to/your/config.toml`.
|
The Codex node can then read the configuration from this file using the `--config-file` CLI parameter, like `codex --config-file=/path/to/your/config.toml`.
|
||||||
|
@ -70,7 +70,7 @@ codex [OPTIONS]... command
|
||||||
The following options are available:
|
The following options are available:
|
||||||
|
|
||||||
--config-file Loads the configuration from a TOML file [=none].
|
--config-file Loads the configuration from a TOML file [=none].
|
||||||
--log-level Sets the log level [=INFO].
|
--log-level Sets the log level [=info].
|
||||||
--metrics Enable the metrics server [=false].
|
--metrics Enable the metrics server [=false].
|
||||||
--metrics-address Listening address of the metrics server [=127.0.0.1].
|
--metrics-address Listening address of the metrics server [=127.0.0.1].
|
||||||
--metrics-port Listening HTTP port of the metrics server [=8008].
|
--metrics-port Listening HTTP port of the metrics server [=8008].
|
||||||
|
@ -111,9 +111,9 @@ codex initNode
|
||||||
Codex uses [Chronicles](https://github.com/status-im/nim-chronicles) logging library, which allows great flexibility in working with logs.
|
Codex uses [Chronicles](https://github.com/status-im/nim-chronicles) logging library, which allows great flexibility in working with logs.
|
||||||
Chronicles has the concept of topics, which categorize log entries into semantic groups.
|
Chronicles has the concept of topics, which categorize log entries into semantic groups.
|
||||||
|
|
||||||
Using the `log-level` parameter, you can set the top-level log level like `--log-level="TRACE"`, but more importantly,
|
Using the `log-level` parameter, you can set the top-level log level like `--log-level="trace"`, but more importantly,
|
||||||
you can set log levels for specific topics like `--log-level="INFO; TRACE: marketplace,node; ERROR: blockexchange"`,
|
you can set log levels for specific topics like `--log-level="info; trace: marketplace,node; error: blockexchange"`,
|
||||||
which sets the top-level log level to `INFO` and then for topics `marketplace` and `node` sets the level to `TRACE` and so on.
|
which sets the top-level log level to `info` and then for topics `marketplace` and `node` sets the level to `trace` and so on.
|
||||||
|
|
||||||
### Example: running two Codex clients
|
### Example: running two Codex clients
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ type
|
||||||
name: "config-file" }: Option[InputFile]
|
name: "config-file" }: Option[InputFile]
|
||||||
|
|
||||||
logLevel* {.
|
logLevel* {.
|
||||||
defaultValue: "INFO"
|
defaultValue: "info"
|
||||||
desc: "Sets the log level",
|
desc: "Sets the log level",
|
||||||
name: "log-level" }: string
|
name: "log-level" }: string
|
||||||
|
|
||||||
|
@ -347,9 +347,9 @@ proc updateLogLevel*(logLevel: string) {.upraises: [ValueError].} =
|
||||||
# Updates log levels (without clearing old ones)
|
# Updates log levels (without clearing old ones)
|
||||||
let directives = logLevel.split(";")
|
let directives = logLevel.split(";")
|
||||||
try:
|
try:
|
||||||
setLogLevel(parseEnum[LogLevel](directives[0]))
|
setLogLevel(parseEnum[LogLevel](directives[0].toUpperAscii))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise (ref ValueError)(msg: "Please specify one of TRACE, DEBUG, INFO, NOTICE, WARN, ERROR or FATAL")
|
raise (ref ValueError)(msg: "Please specify one of: trace, debug, info, notice, warn, error or fatal")
|
||||||
|
|
||||||
if directives.len > 1:
|
if directives.len > 1:
|
||||||
for topicName, settings in parseTopicDirectives(directives[1..^1]):
|
for topicName, settings in parseTopicDirectives(directives[1..^1]):
|
||||||
|
|
Loading…
Reference in New Issue