File tree Expand file tree Collapse file tree 2 files changed +10
-7
lines changed
Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -8,21 +8,22 @@ use std::{
88pub fn handle_receive ( addr : impl ToSocketAddrs , output_path : & str ) {
99 let output_path = PathBuf :: from ( output_path) ;
1010 create_dir_all ( & output_path) . unwrap ( ) ;
11- tracing:: debug !( "保存文件的目录:{}" , output_path. display( ) ) ;
11+ tracing:: info !( "保存文件的目录:{}" , output_path. display( ) ) ;
1212
1313 let stream = TcpListener :: bind ( addr) . unwrap ( ) ;
14- tracing:: debug !( "服务器启动,监听{}" , stream. local_addr( ) . unwrap( ) ) ;
14+ tracing:: info !( "服务器启动,监听{}" , stream. local_addr( ) . unwrap( ) ) ;
1515
1616 loop {
1717 let output_path = output_path. clone ( ) ;
1818
1919 let ( stream, a) = stream. accept ( ) . unwrap ( ) ;
20- tracing:: debug !( "新连接:{}" , a) ;
20+ tracing:: info !( "新连接:{}" , a) ;
2121
22+ tracing:: info!( "接收文件中..." ) ;
2223 std:: thread:: spawn ( move || {
2324 let mut stream = ReceiveProtocol :: new ( stream) ;
2425 stream. receive_file_or_dir ( & output_path) ;
25- tracing:: debug !( "接收任务完成" ) ;
26+ tracing:: info !( "接收任务完成" ) ;
2627 } ) ;
2728 }
2829}
Original file line number Diff line number Diff line change @@ -7,27 +7,29 @@ use std::{
77use walkdir:: WalkDir ;
88
99pub fn handle_send ( addr : impl ToSocketAddrs , send_path : & str ) {
10- let start_time = Instant :: now ( ) ;
11-
1210 let send_path = PathBuf :: from ( send_path) ;
1311 if !send_path. exists ( ) {
1412 panic ! ( "需要发送的路径{}不存在" , send_path. display( ) ) ;
1513 }
1614
1715 let stream = TcpStream :: connect ( addr) . unwrap ( ) ;
16+ tracing:: info!( "连接到服务器成功" ) ;
1817
1918 let mut stream = SendProtocol :: new ( stream) ;
2019
2120 let root_dir = send_path. parent ( ) . unwrap ( ) ;
2221
2322 let paths = WalkDir :: new ( & send_path) ;
2423
24+ tracing:: info!( "发送文件中..." ) ;
25+ let start_time = Instant :: now ( ) ;
2526 for entry in paths {
2627 let entry = entry. unwrap ( ) ;
2728 let path = entry. path ( ) ;
2829
2930 stream. send_file_or_dir ( path, root_dir) ;
3031 }
32+
3133 stream. flush ( ) ;
32- tracing:: debug !( "发送任务完成,耗时: {:?}" , start_time. elapsed( ) ) ;
34+ tracing:: info !( "发送任务完成,耗时: {:?}" , start_time. elapsed( ) ) ;
3335}
You can’t perform that action at this time.
0 commit comments