0

运行基板节点时,如何根据日志行中存在的单词或模式过滤日志行?

我试过运行:

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  
4

1 回答 1

2

一个简单的解决方案:如果您将 stdout 和 stderr 重定向到一个文件(&>命令)中,您可以使用您喜欢的任何方法对其进行过滤。

您可能还想使用tee 命令在终端和文件中查看输出

于 2021-03-03T21:51:41.793 回答