Skip to content

feat(logger): use RUST_LOG-like EnvFilter for logging#4837

Merged
Erigara merged 5 commits intohyperledger-iroha:mainfrom
Erigara:rust_log
Jul 12, 2024
Merged

feat(logger): use RUST_LOG-like EnvFilter for logging#4837
Erigara merged 5 commits intohyperledger-iroha:mainfrom
Erigara:rust_log

Conversation

@Erigara
Copy link
Copy Markdown
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
@github-actions
Copy link
Copy Markdown

@BAStos525

@Erigara
Copy link
Copy Markdown
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
Copy Markdown
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?

@Erigara
Copy link
Copy Markdown
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

Erigara added 5 commits July 12, 2024 12:29
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
0x009922 added a commit to 0x009922/iroha that referenced this pull request Mar 28, 2025
…outes

Close hyperledger-iroha#5365
Close hyperledger-iroha#5247
Revert hyperledger-iroha#4837

Signed-off-by: 0x009922 <43530070+0x009922@users.noreply.github.com>
0x009922 added a commit to 0x009922/iroha that referenced this pull request Mar 28, 2025
…outes

Close hyperledger-iroha#5365
Close hyperledger-iroha#5247
Revert hyperledger-iroha#4837

Signed-off-by: 0x009922 <43530070+0x009922@users.noreply.github.com>
0x009922 added a commit to 0x009922/iroha that referenced this pull request Mar 31, 2025
…outes

Close hyperledger-iroha#5365
Close hyperledger-iroha#5247
Revert hyperledger-iroha#4837

Signed-off-by: 0x009922 <43530070+0x009922@users.noreply.github.com>
0x009922 added a commit that referenced this pull request Apr 4, 2025
…outes (#5384)

* refactor: revert `logger.level`, add `logger.filter`, extend config routes

Close #5365
Close #5247
Revert #4837

Signed-off-by: 0x009922 <43530070+0x009922@users.noreply.github.com>

* test: fix torii pytests

Signed-off-by: 0x009922 <43530070+0x009922@users.noreply.github.com>

---------

Signed-off-by: 0x009922 <43530070+0x009922@users.noreply.github.com>
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