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: store logs in different folders based on the chain #3948

Merged
merged 6 commits into from
Jul 31, 2023

Conversation

alessandromazza98
Copy link
Contributor

Closes #3858

When --log.persistent flag is enabled, logs are now stored in different folders based on the chain or in the already-chain-specific --datadir.

Examples (no --datadir flag):
~/.cache/reth/logs/mainnet/reth.log
~/.cache/reth/logs/sepolia/reth.log

Examples (with --datadir flag):
~/custom-data-dir/reth.log

@Rjected Rjected self-requested a review July 27, 2023 21:59
@codecov
Copy link

codecov bot commented Jul 27, 2023

Codecov Report

Merging #3948 (86deeff) into main (56b2ef1) will decrease coverage by 0.04%.
Report is 1 commits behind head on main.
The diff coverage is 65.00%.

Impacted file tree graph

Files Changed Coverage Δ
bin/reth/src/dirs.rs 71.01% <0.00%> (-1.58%) ⬇️
bin/reth/src/cli.rs 34.40% <76.47%> (+12.33%) ⬆️

... and 8 files with indirect coverage changes

Flag Coverage Δ
integration-tests 16.34% <0.00%> (-0.01%) ⬇️
unit-tests 64.31% <65.00%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
reth binary 26.88% <65.00%> (+0.20%) ⬆️
blockchain tree 83.04% <ø> (ø)
pipeline 89.82% <ø> (ø)
storage (db) 74.30% <ø> (ø)
trie 94.70% <ø> (ø)
txpool 45.40% <ø> (-0.61%) ⬇️
networking 77.62% <ø> (-0.05%) ⬇️
rpc 58.52% <ø> (ø)
consensus 63.51% <ø> (ø)
revm 33.08% <ø> (ø)
payload builder 6.58% <ø> (ø)
primitives 87.92% <ø> (-0.02%) ⬇️

Copy link
Member

@Rjected Rjected left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like a good start! is it possible to get a CLI test for this?

for example like the ones here:

#[test]
fn parse_db_path() {
let cmd = Command::try_parse_from(["reth"]).unwrap();
let data_dir = cmd.datadir.unwrap_or_chain_default(cmd.chain.chain);
let db_path = data_dir.db_path();
assert!(db_path.ends_with("reth/mainnet/db"), "{:?}", cmd.config);
let cmd = Command::try_parse_from(["reth", "--datadir", "my/custom/path"]).unwrap();
let data_dir = cmd.datadir.unwrap_or_chain_default(cmd.chain.chain);
let db_path = data_dir.db_path();
assert_eq!(db_path, Path::new("my/custom/path/db"));
}

bin/reth/src/cli.rs Outdated Show resolved Hide resolved
bin/reth/src/cli.rs Outdated Show resolved Hide resolved
@alessandromazza98
Copy link
Contributor Author

At the end I chose the following option:

  • keep logs and datadir directories separate, always using the Logs directory for logs.

This actually turned out the best decision because you can delete some fields to the Cli struct: the datadir field because it is no longer needed since logs are always stored in their specific directory, which is tied to the chain's name.

I also added a test to verify that the directory is properly parsed.

Let me know what do you think.

@onbjerg onbjerg changed the title store logs in different folders based on the chain feat: store logs in different folders based on the chain Jul 31, 2023
@onbjerg onbjerg added C-enhancement New feature or request M-changelog This change should be included in the changelog A-observability Related to tracing, metrics, logs and other observability tools A-cli Related to the reth CLI labels Jul 31, 2023
Copy link
Member

@onbjerg onbjerg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me, thank you. There are some conflicts to solve

@onbjerg onbjerg enabled auto-merge July 31, 2023 13:01
@onbjerg onbjerg requested a review from Rjected July 31, 2023 13:18
Copy link
Member

@Rjected Rjected left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense and looks good to me! thank you!

@onbjerg onbjerg added this pull request to the merge queue Jul 31, 2023
Merged via the queue into paradigmxyz:main with commit 5823255 Jul 31, 2023
23 checks passed
@alessandromazza98 alessandromazza98 deleted the issue3858 branch August 1, 2023 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cli Related to the reth CLI A-observability Related to tracing, metrics, logs and other observability tools C-enhancement New feature or request M-changelog This change should be included in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Store logs in different folders based on the chain
3 participants