Skip to content

Commit

Permalink
Add env_logger and add force-debug feature (#1205)
Browse files Browse the repository at this point in the history
* add env_logger and add force-debug feature

* taplo fmt, fix copyrights

* Update zrml/styx/src/mock.rs

Co-authored-by: Malte Kliemann <[email protected]>

* Update zrml/rikiddo/src/mock.rs

Co-authored-by: Malte Kliemann <[email protected]>

* update comment to clarify logging

---------

Co-authored-by: Malte Kliemann <[email protected]>
  • Loading branch information
Chralt98 and maltekliemann authored Dec 12, 2023
1 parent 53b0f64 commit 8790095
Show file tree
Hide file tree
Showing 31 changed files with 86 additions and 5 deletions.
21 changes: 18 additions & 3 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ sp-arithmetic = { git = "https://github.com/paritytech/substrate", branch = "pol
sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false }
sp-consensus-aura = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false }
sp-debug-derive = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false }
sp-finality-grandpa = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false }
sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false }
Expand Down Expand Up @@ -246,6 +247,7 @@ zrml-swaps-runtime-api = { path = "zrml/swaps/runtime-api", default-features = f

# Other (client)
clap = "4.0.32"
env_logger = "0.10.1"
jsonrpsee = "0.16.2"
libfuzzer-sys = "0.4.7"
more-asserts = "0.3.1"
Expand Down
3 changes: 3 additions & 0 deletions runtime/battery-station/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ scale-info = { workspace = true, features = ["derive"] }
sp-api = { workspace = true }
sp-block-builder = { workspace = true }
sp-core = { workspace = true }
sp-debug-derive = { workspace = true }
sp-inherents = { workspace = true }
sp-offchain = { workspace = true }
sp-runtime = { workspace = true }
Expand Down Expand Up @@ -412,6 +413,8 @@ try-runtime = [
"cumulus-pallet-xcmp-queue?/try-runtime",
"parachain-info?/try-runtime",
]
# Allow to print logs details (no wasm:stripped)
force-debug = ["sp-debug-derive/force-debug"]

[package]
authors = ["Zeitgeist PM <[email protected]>"]
Expand Down
3 changes: 3 additions & 0 deletions runtime/zeitgeist/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ scale-info = { workspace = true, features = ["derive"] }
sp-api = { workspace = true }
sp-block-builder = { workspace = true }
sp-core = { workspace = true }
sp-debug-derive = { workspace = true }
sp-inherents = { workspace = true }
sp-offchain = { workspace = true }
sp-runtime = { workspace = true }
Expand Down Expand Up @@ -401,6 +402,8 @@ try-runtime = [
"cumulus-pallet-xcmp-queue?/try-runtime",
"parachain-info?/try-runtime",
]
# Allow to print logs details (no wasm:stripped)
force-debug = ["sp-debug-derive/force-debug"]

[package]
authors = ["Zeitgeist PM <[email protected]>"]
Expand Down
3 changes: 2 additions & 1 deletion scripts/benchmarks/quick_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export PROFILE=release
export PROFILE_DIR=release
export ADDITIONAL_PARAMS=--detailed-log-output
export EXECUTION=native
export ADDITIONAL_FEATURES=""
# force-debug for no <wasm::stripped> output
export ADDITIONAL_FEATURES="force-debug"

source ./scripts/benchmarks/run_benchmarks.sh
1 change: 1 addition & 0 deletions zrml/authorized/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ zeitgeist-primitives = { workspace = true }
zrml-market-commons = { workspace = true }

[dev-dependencies]
env_logger = { workspace = true }
pallet-balances = { workspace = true, features = ["default"] }
pallet-timestamp = { workspace = true, features = ["default"] }
sp-io = { workspace = true, features = ["default"] }
Expand Down
3 changes: 3 additions & 0 deletions zrml/authorized/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ impl ExtBuilder {
pub fn build(self) -> sp_io::TestExternalities {
let mut t = frame_system::GenesisConfig::default().build_storage::<Runtime>().unwrap();

// see the logs in tests when using `RUST_LOG=debug cargo test -- --nocapture`
let _ = env_logger::builder().is_test(true).try_init();

pallet_balances::GenesisConfig::<Runtime> { balances: self.balances }
.assimilate_storage(&mut t)
.unwrap();
Expand Down
1 change: 1 addition & 0 deletions zrml/court/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ zeitgeist-primitives = { workspace = true }
zrml-market-commons = { workspace = true }

[dev-dependencies]
env_logger = { workspace = true }
pallet-balances = { workspace = true, features = ["default"] }
pallet-randomness-collective-flip = { workspace = true, features = ["default"] }
pallet-timestamp = { workspace = true, features = ["default"] }
Expand Down
3 changes: 3 additions & 0 deletions zrml/court/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,9 @@ impl ExtBuilder {
pub fn build(self) -> sp_io::TestExternalities {
let mut t = frame_system::GenesisConfig::default().build_storage::<Runtime>().unwrap();

// see the logs in tests when using `RUST_LOG=debug cargo test -- --nocapture`
let _ = env_logger::builder().is_test(true).try_init();

pallet_balances::GenesisConfig::<Runtime> { balances: self.balances }
.assimilate_storage(&mut t)
.unwrap();
Expand Down
1 change: 1 addition & 0 deletions zrml/global-disputes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ num-traits = { workspace = true, optional = true }


[dev-dependencies]
env_logger = { workspace = true }
pallet-balances = { workspace = true, features = ["default"] }
pallet-timestamp = { workspace = true, features = ["default"] }
sp-io = { workspace = true, features = ["default"] }
Expand Down
3 changes: 3 additions & 0 deletions zrml/global-disputes/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ impl ExtBuilder {
pub fn build(self) -> sp_io::TestExternalities {
let mut t = frame_system::GenesisConfig::default().build_storage::<Runtime>().unwrap();

// see the logs in tests when using `RUST_LOG=debug cargo test -- --nocapture`
let _ = env_logger::builder().is_test(true).try_init();

pallet_balances::GenesisConfig::<Runtime> { balances: self.balances }
.assimilate_storage(&mut t)
.unwrap();
Expand Down
1 change: 1 addition & 0 deletions zrml/liquidity-mining/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ zeitgeist-primitives = { workspace = true }
zrml-market-commons = { workspace = true }

[dev-dependencies]
env_logger = { workspace = true }
pallet-balances = { workspace = true, features = ["default"] }
pallet-timestamp = { workspace = true, features = ["default"] }
sp-io = { workspace = true, features = ["default"] }
Expand Down
3 changes: 3 additions & 0 deletions zrml/liquidity-mining/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ impl ExtBuilder {
pub fn build(self) -> sp_io::TestExternalities {
let mut t = frame_system::GenesisConfig::default().build_storage::<Runtime>().unwrap();

// see the logs in tests when using `RUST_LOG=debug cargo test -- --nocapture`
let _ = env_logger::builder().is_test(true).try_init();

crate::GenesisConfig::<Runtime> {
initial_balance: self.initial_balance,
per_block_distribution: self.per_block_incentives,
Expand Down
1 change: 1 addition & 0 deletions zrml/market-commons/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ sp-runtime = { workspace = true }
zeitgeist-primitives = { workspace = true }

[dev-dependencies]
env_logger = { workspace = true }
pallet-balances = { workspace = true, features = ["default"] }
pallet-timestamp = { workspace = true, features = ["default"] }
sp-io = { workspace = true, features = ["default"] }
Expand Down
3 changes: 3 additions & 0 deletions zrml/market-commons/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ impl ExtBuilder {
pub fn build(self) -> sp_io::TestExternalities {
let mut t = frame_system::GenesisConfig::default().build_storage::<Runtime>().unwrap();

// see the logs in tests when using `RUST_LOG=debug cargo test -- --nocapture`
let _ = env_logger::builder().is_test(true).try_init();

pallet_balances::GenesisConfig::<Runtime> { balances: vec![] }
.assimilate_storage(&mut t)
.unwrap();
Expand Down
3 changes: 2 additions & 1 deletion zrml/neo-swaps/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ zrml-market-commons = { workspace = true }

# Mock

env_logger = { workspace = true, optional = true }
orml-asset-registry = { workspace = true, optional = true }
orml-currencies = { workspace = true, optional = true }
orml-tokens = { workspace = true, optional = true }
Expand All @@ -38,7 +39,6 @@ zrml-rikiddo = { workspace = true, optional = true }
zrml-simple-disputes = { workspace = true, optional = true }
zrml-swaps = { workspace = true, optional = true }


[dev-dependencies]
more-asserts = { workspace = true }
test-case = { workspace = true }
Expand Down Expand Up @@ -77,6 +77,7 @@ mock = [
"zrml-prediction-markets/mock",
"zrml-prediction-markets/default",
"serde/default",
"env_logger/default",
]
parachain = ["zrml-prediction-markets/parachain"]
runtime-benchmarks = [
Expand Down
2 changes: 2 additions & 0 deletions zrml/neo-swaps/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,8 @@ impl Default for ExtBuilder {
impl ExtBuilder {
pub fn build(self) -> sp_io::TestExternalities {
let mut t = frame_system::GenesisConfig::default().build_storage::<Runtime>().unwrap();
// see the logs in tests when using `RUST_LOG=debug cargo test -- --nocapture`
let _ = env_logger::builder().is_test(true).try_init();
pallet_balances::GenesisConfig::<Runtime> { balances: self.balances }
.assimilate_storage(&mut t)
.unwrap();
Expand Down
2 changes: 2 additions & 0 deletions zrml/orderbook/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ sp-runtime = { workspace = true }
zeitgeist-primitives = { workspace = true }

# Mock
env_logger = { workspace = true, optional = true }
orml-currencies = { workspace = true, optional = true }
orml-tokens = { workspace = true, optional = true }
pallet-balances = { workspace = true, optional = true }
Expand All @@ -31,6 +32,7 @@ mock = [
"orml-currencies/default",
"sp-io/default",
"zeitgeist-primitives/mock",
"env_logger/default",
]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
Expand Down
3 changes: 3 additions & 0 deletions zrml/orderbook/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ impl ExtBuilder {
pub fn build(self) -> sp_io::TestExternalities {
let mut t = frame_system::GenesisConfig::default().build_storage::<Runtime>().unwrap();

// see the logs in tests when using `RUST_LOG=debug cargo test -- --nocapture`
let _ = env_logger::builder().is_test(true).try_init();

pallet_balances::GenesisConfig::<Runtime> { balances: self.balances }
.assimilate_storage(&mut t)
.unwrap();
Expand Down
1 change: 1 addition & 0 deletions zrml/parimutuel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ zeitgeist-primitives = { workspace = true }
zrml-market-commons = { workspace = true }

[dev-dependencies]
env_logger = { workspace = true }
orml-currencies = { workspace = true, features = ["default"] }
orml-tokens = { workspace = true, features = ["default"] }
pallet-balances = { workspace = true, features = ["default"] }
Expand Down
3 changes: 3 additions & 0 deletions zrml/parimutuel/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ impl ExtBuilder {
pub fn build(self) -> sp_io::TestExternalities {
let mut t = frame_system::GenesisConfig::default().build_storage::<Runtime>().unwrap();

// see the logs in tests when using `RUST_LOG=debug cargo test -- --nocapture`
let _ = env_logger::builder().is_test(true).try_init();

pallet_balances::GenesisConfig::<Runtime> { balances: self.balances }
.assimilate_storage(&mut t)
.unwrap();
Expand Down
2 changes: 2 additions & 0 deletions zrml/prediction-markets/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ zrml-simple-disputes = { workspace = true }

# Mock

env_logger = { workspace = true, optional = true }
orml-asset-registry = { workspace = true, optional = true }
orml-currencies = { workspace = true, optional = true }
orml-tokens = { workspace = true, optional = true }
Expand Down Expand Up @@ -57,6 +58,7 @@ mock = [
"zrml-swaps/default",
"xcm/default",
"orml-asset-registry/default",
"env_logger/default",
]
parachain = []
runtime-benchmarks = [
Expand Down
3 changes: 3 additions & 0 deletions zrml/prediction-markets/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,9 @@ impl ExtBuilder {
pub fn build(self) -> sp_io::TestExternalities {
let mut t = frame_system::GenesisConfig::default().build_storage::<Runtime>().unwrap();

// see the logs in tests when using `RUST_LOG=debug cargo test -- --nocapture`
let _ = env_logger::builder().is_test(true).try_init();

pallet_balances::GenesisConfig::<Runtime> { balances: self.balances }
.assimilate_storage(&mut t)
.unwrap();
Expand Down
Loading

0 comments on commit 8790095

Please sign in to comment.