过滤基质日志
Filtering substrate logs
当 运行 底层节点时,如何根据日志行中出现的单词或模式过滤日志行?
我试过了运行:
RUST_LOG=runtime=debug cargo run -- --dev | grep 'INFO'
然而,这仍然给我输出的所有行,例如:
2021-03-03 12:01:18.292 DEBUG main runtime: Called should_end_session
2021-03-03 12:01:18.292 DEBUG main runtime: Cannot fetch slot number
2021-03-03 12:01:18.684 INFO main sc_service::builder: Highest known block at #41
2021-03-03 12:01:18.688 INFO tokio-runtime-worker substrate_prometheus_endpoint::known_os: 〽️ Prometheus server started at 127.0.0.1:9615
2021-03-03 12:01:18.708 INFO main parity_ws: Listening for new connections on 127.0.0.1:9944.
2021-03-03 12:01:18.963 INFO ThreadId(33) parity_ws::io: Accepted a new tcp connection from 127.0.0.1:62079.
2021-03-03 12:01:19.131 WARN event.loop0 sc_rpc_api::errors: Unknown error: Client(UnknownBlock("header not found in db: 0x6eb1…618b"))
2021-03-03 12:01:19.132 WARN event.loop0 sc_rpc_api::errors: Unknown error: Client(UnknownBlock("header not found in db: 0x6eb1…618b"))
2021-03-03 12:01:20.124 INFO ThreadId(33) parity_ws::io: Accepted a new tcp connection from 127.0.0.1:62080.
2021-03-03 12:01:21.433 DEBUG tokio-runtime-worker runtime: Called should_end_session
2021-03-03 12:01:21.433 DEBUG tokio-runtime-worker runtime: Cannot fetch slot number
2021-03-03 12:01:21.536 INFO tokio-runtime-worker sc_basic_authorship::basic_authorship: Starting consensus session on top of parent 0xa246d8880f1a820bb2275b78e728471c38c3406271d12b3f852fa717a5338c95
一个简单的解决方案:如果您 redirect stdout and stderr 进入一个文件(&>
命令),您可以使用您喜欢的任何方法过滤它。
您可能还想使用 tee command 在终端和文件中查看输出
当 运行 底层节点时,如何根据日志行中出现的单词或模式过滤日志行?
我试过了运行:
RUST_LOG=runtime=debug cargo run -- --dev | grep 'INFO'
然而,这仍然给我输出的所有行,例如:
2021-03-03 12:01:18.292 DEBUG main runtime: Called should_end_session
2021-03-03 12:01:18.292 DEBUG main runtime: Cannot fetch slot number
2021-03-03 12:01:18.684 INFO main sc_service::builder: Highest known block at #41
2021-03-03 12:01:18.688 INFO tokio-runtime-worker substrate_prometheus_endpoint::known_os: 〽️ Prometheus server started at 127.0.0.1:9615
2021-03-03 12:01:18.708 INFO main parity_ws: Listening for new connections on 127.0.0.1:9944.
2021-03-03 12:01:18.963 INFO ThreadId(33) parity_ws::io: Accepted a new tcp connection from 127.0.0.1:62079.
2021-03-03 12:01:19.131 WARN event.loop0 sc_rpc_api::errors: Unknown error: Client(UnknownBlock("header not found in db: 0x6eb1…618b"))
2021-03-03 12:01:19.132 WARN event.loop0 sc_rpc_api::errors: Unknown error: Client(UnknownBlock("header not found in db: 0x6eb1…618b"))
2021-03-03 12:01:20.124 INFO ThreadId(33) parity_ws::io: Accepted a new tcp connection from 127.0.0.1:62080.
2021-03-03 12:01:21.433 DEBUG tokio-runtime-worker runtime: Called should_end_session
2021-03-03 12:01:21.433 DEBUG tokio-runtime-worker runtime: Cannot fetch slot number
2021-03-03 12:01:21.536 INFO tokio-runtime-worker sc_basic_authorship::basic_authorship: Starting consensus session on top of parent 0xa246d8880f1a820bb2275b78e728471c38c3406271d12b3f852fa717a5338c95
一个简单的解决方案:如果您 redirect stdout and stderr 进入一个文件(&>
命令),您可以使用您喜欢的任何方法过滤它。
您可能还想使用 tee command 在终端和文件中查看输出