1- use std:: fmt:: { Display , Formatter } ;
2- use std:: pin:: Pin ;
3- use futures:: { Sink , Stream , StreamExt } ;
41use anyhow:: Result ;
52use async_stream:: stream;
6- use std:: collections:: HashMap ;
73use async_trait:: async_trait;
4+ use futures:: { Sink , Stream , StreamExt } ;
85use regex:: Regex ;
9- use tokio :: io :: AsyncBufReadExt ;
6+ use std :: collections :: HashMap ;
107use std:: error:: Error ;
8+ use std:: fmt:: { Display , Formatter } ;
9+ use std:: pin:: Pin ;
10+ use tokio:: io:: AsyncBufReadExt ;
1111use tokio:: process:: { Child , Command } ;
1212
1313#[ derive( Debug , Clone ) ]
@@ -24,11 +24,15 @@ pub(crate) struct Log {
2424
2525impl Display for Log {
2626 fn fmt ( & self , f : & mut Formatter < ' _ > ) -> std:: fmt:: Result {
27- write ! ( f, "{} {} {} {} {} {} {}" , self . date, self . time, self . pid, self . tid, self . level, self . tag, self . message)
27+ write ! (
28+ f,
29+ "{} {} {} {} {} {} {}" ,
30+ self . date, self . time, self . pid, self . tid, self . level, self . tag, self . message
31+ )
2832 }
2933}
3034
31- type LogStream = Pin < Box < dyn Stream < Item = Result < Log , Box < dyn Error + Send > > > + Send > > ;
35+ type LogStream = Pin < Box < dyn Stream < Item = Result < Log , Box < dyn Error + Send > > > + Send > > ;
3236
3337#[ async_trait]
3438trait Source {
@@ -45,8 +49,7 @@ impl AdbSource {
4549 command. arg ( "-D" ) ;
4650 command. arg ( "-v" ) . arg ( "long" ) ;
4751 command. arg ( "-b" ) . arg ( "all" ) ;
48- command. spawn ( )
49- . expect ( "Failed to execute adb logcat" )
52+ command. spawn ( ) . expect ( "Failed to execute adb logcat" )
5053 }
5154}
5255
@@ -55,7 +58,9 @@ impl Source for AdbSource {
5558 async fn source ( & self ) -> LogStream {
5659 let mut logcat = self . spawn_adb_logcat ( ) . await ;
5760 let mut reader = tokio:: io:: BufReader :: new ( logcat. stdout . take ( ) . unwrap ( ) ) ;
58- let re = Regex :: new ( r"\[ (\d{2}-\d{2})\s(\d{2}:\d{2}:\d{2}\.\d{3})\s+(\d+):\s+(\d+)\s+(.*) ]" ) . unwrap ( ) ;
61+ let re =
62+ Regex :: new ( r"\[ (\d{2}-\d{2})\s(\d{2}:\d{2}:\d{2}\.\d{3})\s+(\d+):\s+(\d+)\s+(.*) ]" )
63+ . unwrap ( ) ;
5964
6065 let s = stream ! {
6166 let mut line = String :: new( ) ;
@@ -125,6 +130,7 @@ async fn main() {
125130 Err ( _) => { }
126131 }
127132 }
128- } ) . await . expect ( "TODO: panic message" ) ;
129-
130- }
133+ } )
134+ . await
135+ . expect ( "TODO: panic message" ) ;
136+ }
0 commit comments