@@ -9,7 +9,8 @@ use crate::tui::explorer::Explorer;
99use crate :: tui:: logger:: Logger ;
1010use crate :: tui:: menu_bar:: MenuBar ;
1111use anyhow:: { Context , Result } ;
12- use libclide_macros:: log_id;
12+ use libclide:: log:: Loggable ;
13+ use libclide_macros:: Loggable ;
1314use ratatui:: DefaultTerminal ;
1415use ratatui:: buffer:: Buffer ;
1516use ratatui:: crossterm:: event;
@@ -30,7 +31,7 @@ pub enum AppComponent {
3031 MenuBar ,
3132}
3233
33- #[ log_id ]
34+ #[ derive ( Loggable ) ]
3435pub struct App < ' a > {
3536 editor_tab : EditorTab ,
3637 explorer : Explorer < ' a > ,
@@ -42,7 +43,7 @@ pub struct App<'a> {
4243
4344impl < ' a > App < ' a > {
4445 pub fn new ( root_path : PathBuf ) -> Result < Self > {
45- libclide:: trace!( target : Self :: ID , "Building {}" , Self :: ID ) ;
46+ libclide:: trace!( "Building {}" , < Self as Loggable > :: ID ) ;
4647 let app = Self {
4748 editor_tab : EditorTab :: new ( ) ,
4849 explorer : Explorer :: new ( & root_path) ?,
@@ -56,13 +57,13 @@ impl<'a> App<'a> {
5657
5758 /// Logic that should be executed once on application startup.
5859 pub fn start ( & mut self ) -> Result < ( ) > {
59- libclide:: trace!( target : Self :: ID , "Starting App" ) ;
60+ libclide:: trace!( "Starting App" ) ;
6061 Ok ( ( ) )
6162 }
6263
6364 pub fn run ( mut self , mut terminal : DefaultTerminal ) -> Result < ( ) > {
6465 self . start ( ) ?;
65- libclide:: trace!( target : Self :: ID , "Entering App run loop" ) ;
66+ libclide:: trace!( "Entering App run loop" ) ;
6667 loop {
6768 terminal. draw ( |f| {
6869 f. render_widget ( & mut self , f. area ( ) ) ;
@@ -88,7 +89,7 @@ impl<'a> App<'a> {
8889 Some ( editor) => editor. component_state . help_text . clone ( ) ,
8990 None => {
9091 if !self . editor_tab . is_empty ( ) {
91- libclide:: error!( target : Self :: ID , "Failed to get Editor while drawing bottom status bar" ) ;
92+ libclide:: error!( "Failed to get Editor while drawing bottom status bar" ) ;
9293 }
9394 "Failed to get current Editor while getting widget help text" . to_string ( )
9495 }
@@ -112,26 +113,26 @@ impl<'a> App<'a> {
112113 }
113114
114115 fn clear_focus ( & mut self ) {
115- libclide:: info!( target : Self :: ID , "Clearing all widget focus" ) ;
116+ libclide:: info!( "Clearing all widget focus" ) ;
116117 self . explorer . component_state . set_focus ( Focus :: Inactive ) ;
117118 self . explorer . component_state . set_focus ( Focus :: Inactive ) ;
118119 self . logger . component_state . set_focus ( Focus :: Inactive ) ;
119120 self . menu_bar . component_state . set_focus ( Focus :: Inactive ) ;
120121 match self . editor_tab . current_editor_mut ( ) {
121122 None => {
122- libclide:: error!( target : Self :: ID , "Failed to get current Editor while clearing focus" )
123+ libclide:: error!( "Failed to get current Editor while clearing focus" )
123124 }
124125 Some ( editor) => editor. component_state . set_focus ( Focus :: Inactive ) ,
125126 }
126127 }
127128
128129 fn change_focus ( & mut self , focus : AppComponent ) {
129- libclide:: info!( target : Self :: ID , "Changing widget focus to {:?}" , focus) ;
130+ libclide:: info!( "Changing widget focus to {:?}" , focus) ;
130131 self . clear_focus ( ) ;
131132 match focus {
132133 AppComponent :: Editor => match self . editor_tab . current_editor_mut ( ) {
133134 None => {
134- libclide:: error!( target : Self :: ID , "Failed to get current Editor while changing focus" )
135+ libclide:: error!( "Failed to get current Editor while changing focus" )
135136 }
136137 Some ( editor) => editor. component_state . set_focus ( Focus :: Active ) ,
137138 } ,
@@ -274,13 +275,15 @@ impl<'a> Component for App<'a> {
274275 Action :: Quit | Action :: Handled => Ok ( action) ,
275276 Action :: Save => match self . editor_tab . current_editor_mut ( ) {
276277 None => {
277- libclide:: error!( target: Self :: ID , "Failed to get current editor while handling App Action::Save" ) ;
278+ libclide:: error!(
279+ "Failed to get current editor while handling App Action::Save"
280+ ) ;
278281 Ok ( Action :: Noop )
279282 }
280283 Some ( editor) => match editor. save ( ) {
281284 Ok ( _) => Ok ( Action :: Handled ) ,
282285 Err ( e) => {
283- libclide:: error!( target : Self :: ID , "Failed to save editor contents: {e}" ) ;
286+ libclide:: error!( "Failed to save editor contents: {e}" ) ;
284287 Ok ( Action :: Noop )
285288 }
286289 } ,
@@ -299,14 +302,16 @@ impl<'a> Component for App<'a> {
299302 Err ( _) => Ok ( Action :: Noop ) ,
300303 } ,
301304 Action :: ReloadFile => {
302- libclide:: trace!( target : Self :: ID , "Reloading file for current editor" ) ;
305+ libclide:: trace!( "Reloading file for current editor" ) ;
303306 if let Some ( editor) = self . editor_tab . current_editor_mut ( ) {
304307 editor
305308 . reload_contents ( )
306309 . map ( |_| Action :: Handled )
307310 . context ( "Failed to handle Action::ReloadFile" )
308311 } else {
309- libclide:: error!( target: Self :: ID , "Failed to get current editor while handling App Action::ReloadFile" ) ;
312+ libclide:: error!(
313+ "Failed to get current editor while handling App Action::ReloadFile"
314+ ) ;
310315 Ok ( Action :: Noop )
311316 }
312317 }
0 commit comments