@@ -149,7 +149,10 @@ impl Args
149149 RustlsConfig :: from_pem_file( self . certificate, self . key) . err_into:: <DynError >( ) ,
150150 ) ?;
151151
152- init_watchman ( permissions. clone ( ) , model_path, policy_path) . await ?;
152+ if let Err ( e) = init_watchman ( permissions. clone ( ) , model_path, policy_path) . await
153+ {
154+ tracing:: error!( "Failed to enable hot-reloading permissions: {e}" ) ;
155+ }
153156
154157 match self . command
155158 {
@@ -215,7 +218,7 @@ fn leak_string(s: String) -> &'static str
215218///
216219/// This allows [`winvoice-server`](crate)'s permissions to be hot-reloaded while the server is
217220/// running.
218- #[ instrument( level = Level :: INFO , fields ( permissions , model_path , policy_path ) ) ]
221+ #[ instrument( level = "trace" ) ]
219222async fn init_watchman (
220223 permissions : Lock < Enforcer > ,
221224 model_path : Option < & ' static str > ,
@@ -252,36 +255,44 @@ async fn init_watchman(
252255 tracing:: info!( "Watching for file changes" ) ;
253256 loop
254257 {
255- match subscription. next ( ) . await ?
258+ match subscription. next ( ) . await
256259 {
257- SubscriptionData :: Canceled =>
260+ Ok ( SubscriptionData :: Canceled ) =>
258261 {
259- tracing:: info !(
262+ tracing:: error !(
260263 "Watchman stopped unexpectedly. Hot reloading permissions is disabled."
261264 ) ;
262265 break ;
263266 } ,
264- SubscriptionData :: FilesChanged ( query) =>
267+ Ok ( SubscriptionData :: FilesChanged ( query) ) =>
265268 {
266- tracing:: trace !( "Notified of file change: {query:#?}" ) ;
269+ tracing:: debug !( "Notified of file change: {query:#?}" ) ;
267270 let mut p = permissions. write ( ) . await ;
268271 * p = match Enforcer :: new ( model_path, policy_path) . await
269272 {
270273 Ok ( e) => e,
271274 Err ( e) =>
272275 {
273- tracing:: debug !( "Could not reload permissions: {e}" ) ;
276+ tracing:: info !( "Could not reload permissions: {e}" ) ;
274277 continue ;
275278 } ,
276279 } ;
277280 } ,
278- _ => ( ) ,
281+ Ok ( event) => tracing:: trace!( "Notified of ignored event: {event}" ) ,
282+ Err ( e) =>
283+ {
284+ tracing:: error!(
285+ "Encountered an error while watching for file changes: {e}. Hot \
286+ reloading permissions is disabled"
287+ ) ;
288+ break ;
289+ } ,
279290 }
280291 }
281292
282293 Ok :: < _ , watchman_client:: Error > ( ( ) )
283294 }
284- . instrument ( tracing:: info_span !( "hot_reload_permissions" ) ) ,
295+ . instrument ( tracing:: error_span !( "hot_reload_permissions" ) ) ,
285296 ) ;
286297
287298 Ok ( ( ) )
0 commit comments