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(logger): use RUST_LOG-like EnvFilter for logging #4837

Merged
merged 5 commits into from
Jul 12, 2024

Conversation

Erigara
Copy link
Contributor

@Erigara Erigara commented Jul 11, 2024

Description

Replace level filter with EnvFilter which support setting specific log level for different iroha modules.

Examples

The same can be done through configuration in config.toml.

# set global logging level to debug
LOG_LEVEL="debug" ./scripts/test_env.py setup
# set global logging level to error and info for iroha_core
LOG_LEVEL="error,iroha_core=info" ./scripts/test_env.py setup
# receive only logs from sumerag with trace level or heigher
LOG_LEVEL="iroha_core::sumeragi" ./scripts/test_env.py setup
# receive all logs at trace level, except axum for which use error
LOG_LEVEL="trace,axum=error" ./scripts/test_env.py setup

Linked issue

Closes #4829

Benefits

More granular control over logging.

Downsides

It's harder to check correctness for example if someone would write LOG_LEVEL=infa iroha won't return any error because this would be parsed as accept logs from module infa at trace level.

I believe we can mitigate this, by custom parsing, but it would make our type more strict than orginal EnvFilter.
It's smt i would prefer to leave for separate PR.

@DCNick3 DCNick3 added the config-changes Changes in configuration and start up of the Iroha label Jul 11, 2024
Copy link

@BAStos525

@Erigara
Copy link
Contributor Author

Erigara commented Jul 11, 2024

@BAStos525 this change is backward compatible, so previous values for LOG_LEVEL and configuration will continue to work.

@mversic
Copy link
Contributor

mversic commented Jul 11, 2024

It's harder to check correctness for example if someone would write LOG_LEVEL=infa iroha won't return any error because this would be parsed as accept logs from module infa at trace level.

why is default TRACE?

config/src/parameters/user.rs Show resolved Hide resolved
logger/src/lib.rs Show resolved Hide resolved
config/src/logger.rs Show resolved Hide resolved
config/src/logger.rs Outdated Show resolved Hide resolved
@Erigara
Copy link
Contributor Author

Erigara commented Jul 11, 2024

It's harder to check correctness for example if someone would write LOG_LEVEL=infa iroha won't return any error because this would be parsed as accept logs from module infa at trace level.

why is default TRACE?

idk, lowest possible level is assumed by tracing crate

Signed-off-by: Shanin Roman <shanin1000@yandex.ru>
Signed-off-by: Shanin Roman <shanin1000@yandex.ru>
Signed-off-by: Shanin Roman <shanin1000@yandex.ru>
Signed-off-by: Shanin Roman <shanin1000@yandex.ru>
Signed-off-by: Shanin Roman <shanin1000@yandex.ru>
@Erigara Erigara merged commit 185ef76 into hyperledger-iroha:main Jul 12, 2024
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
config-changes Changes in configuration and start up of the Iroha
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: introduce RUST_LOG like log level format
3 participants