@@ -4,7 +4,7 @@ use anyhow::{bail, Context};
44use rumqttc:: v5:: { MqttOptions , AsyncClient , EventLoop , Event , Incoming , ClientError } ;
55use rumqttc:: v5:: mqttbytes:: QoS ;
66use tokio:: sync:: broadcast;
7- use tracing:: { debug, error, warn} ;
7+ use tracing:: { debug, error, info , warn} ;
88
99use crate :: config:: Config ;
1010use crate :: handler:: { RequestMessage , ResponseMessage } ;
@@ -17,6 +17,7 @@ pub struct Connection {
1717
1818impl Connection {
1919 pub async fn connect ( config : Arc < Config > ) -> anyhow:: Result < ( Self , EventLoop ) > {
20+ info ! ( "begin to connect mqtt server: {}" , & config. server) ;
2021 let mqtt_url = format ! ( "{}?client_id={}" , & config. server, & config. client_id) ;
2122 let mut options = MqttOptions :: parse_url ( & mqtt_url) . with_context ( || format ! ( "parser mqtt url fail: {:?}" , & mqtt_url) ) ?;
2223
@@ -31,6 +32,7 @@ impl Connection {
3132 let ( client, eventloop) = AsyncClient :: new ( options, 20 ) ;
3233 let topic = config. get_command_topic ( ) ;
3334 let _ = client. subscribe ( topic, QoS :: ExactlyOnce ) . await ?;
35+ info ! ( "connect mqtt server successful" ) ;
3436 Ok ( ( Connection {
3537 client,
3638 } , eventloop) )
0 commit comments