Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ha#4064, hyperledger-iroha#4079: re-architect logger and dynamic configuration (hyperledger-iroha#4100)

Co-authored-by: ⭐️NINIKA⭐️ <[email protected]>
Signed-off-by: Dmitry Balashov <[email protected]>
  • Loading branch information
2 people authored and Asem-Abdelhady committed Feb 9, 2024
1 parent 6f2c04c commit 7c7f340
Show file tree
Hide file tree
Showing 48 changed files with 1,072 additions and 1,196 deletions.
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ Follow these commit guidelines:
<details> <summary> Expand to learn how to change the log level or write logs to a JSON.</summary>
If one of your tests is failing, you may want to decrease the maximum logging level. By default, Iroha only logs `INFO` level messages, but retains the ability to produce both `DEBUG` and `TRACE` level logs. This setting can be changed either using the `MAX_LOG_LEVEL` environment variable for code-based tests, or using the `/configuration` endpoint on one of the peers in a deployed network.
If one of your tests is failing, you may want to decrease the maximum logging level. By default, Iroha only logs `INFO` level messages, but retains the ability to produce both `DEBUG` and `TRACE` level logs. This setting can be changed either using the `LOG_LEVEL` environment variable for code-based tests, or using the `/configuration` endpoint on one of the peers in a deployed network.
While logs printed in the `stdout` are sufficient, you may find it more convenient to produce `json`-formatted logs into a separate file and parse them using either [node-bunyan](https://www.npmjs.com/package/bunyan) or [rust-bunyan](https://crates.io/crates/bunyan).
Expand All @@ -251,16 +251,16 @@ In this case you should compile iroha with support of tokio console like that:
RUSTFLAGS="--cfg tokio_unstable" cargo build --features tokio-console
```

Port for tokio console can by configured through `TOKIO_CONSOLE_ADDR` configuration parameter (or environment variable).
Using tokio console require log level to be `TRACE`, can be enabled through configuration parameter or environment variable `MAX_LOG_LEVEL`.
Port for tokio console can by configured through `LOG_TOKIO_CONSOLE_ADDR` configuration parameter (or environment variable).
Using tokio console require log level to be `TRACE`, can be enabled through configuration parameter or environment variable `LOG_LEVEL`.

Example of running iroha with tokio console support using `scripts/test_env.sh`:

```bash
# 1. Compile iroha
RUSTFLAGS="--cfg tokio_unstable" cargo build --features tokio-console
# 2. Run iroha with TRACE log level
MAX_LOG_LEVEL=TRACE ./scripts/test_env.sh setup
LOG_LEVEL=TRACE ./scripts/test_env.sh setup
# 3. Access iroha. Peers will be available on ports 5555, 5556, ...
tokio-console http://127.0.0.1:5555
```
Expand Down
43 changes: 9 additions & 34 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ For a list of all endpoints, available operations, and ways to customize them wi

By default, Iroha provides logs in a human-readable format and prints them out to `stdout`.

The logging level can be changed either via a [configuration option](./docs/source/references/config.md#loggermax_log_level) or at run-time using the `configuration` endpoint.
The logging level can be changed either via the [`logger.level` configuration parameter](./docs/source/references/config.md#loggerlevel) or at run-time using the `configuration` endpoint.

<details><summary>Example: changing log level</summary>

Expand All @@ -178,17 +178,13 @@ For example, if your Iroha instance is running at `127.0.0.1:8080` and you want
curl -X POST \
-H 'content-type: application/json' \
http://127.0.0.1:8080/configuration \
-d '{"LogLevel": "DEBUG"}' -i
-d '{"logger": {"level": "DEBUG"}}' -i
```
</details>

#### JSON Logging Mode
The log format might be configured via the [`logger.format` configuration parameter](./docs/source/references/config.md#loggerformat). Possible values are: `full` (default), `compact`, `pretty`, and `json`.

Additionally, Iroha supports a JSON logging mode.

To enable it, provide the [logging file](./docs/source/references/config.md#loggerlog_file_path) to store the logs in. On UNIX, you can also specify `/dev/stdout` or `/dev/stderr` if you prefer to pipe the output to [`bunyan`](https://www.npmjs.com/package/bunyan).

[Log rotation](https://www.commandlinux.com/man-page/man5/logrotate.conf.5.html) is the responsibility of the peer administrator.
Output goes to `/dev/stdout`. Piping to files or [log rotation](https://www.commandlinux.com/man-page/man5/logrotate.conf.5.html) is the responsibility of the peer administrator.

### Monitoring

Expand Down
Loading

0 comments on commit 7c7f340

Please sign in to comment.