@@ -25,8 +25,6 @@ use tower_lsp_server::lsp_types::WorkspaceServerCapabilities;
2525use tower_lsp_server:: LanguageServer ;
2626use tracing_appender:: non_blocking:: WorkerGuard ;
2727
28- use crate :: log_error;
29- use crate :: log_info;
3028use crate :: queue:: Queue ;
3129use crate :: session:: Session ;
3230
@@ -58,7 +56,7 @@ impl DjangoLanguageServer {
5856 if let Some ( s) = & * session {
5957 f ( s)
6058 } else {
61- log_error ! ( "Attempted to access session before initialization" ) ;
59+ tracing :: error !( "Attempted to access session before initialization" ) ;
6260 R :: default ( )
6361 }
6462 }
@@ -72,7 +70,7 @@ impl DjangoLanguageServer {
7270 if let Some ( s) = & mut * session {
7371 f ( s)
7472 } else {
75- log_error ! ( "Attempted to access session before initialization" ) ;
73+ tracing :: error !( "Attempted to access session before initialization" ) ;
7674 R :: default ( )
7775 }
7876 }
@@ -85,16 +83,16 @@ impl DjangoLanguageServer {
8583 let session_arc = Arc :: clone ( & self . session ) ;
8684
8785 if let Err ( e) = self . queue . submit ( async move { f ( session_arc) . await } ) . await {
88- log_error ! ( "Failed to submit task: {}" , e) ;
86+ tracing :: error !( "Failed to submit task: {}" , e) ;
8987 } else {
90- log_info ! ( "Task submitted successfully" ) ;
88+ tracing :: info !( "Task submitted successfully" ) ;
9189 }
9290 }
9391}
9492
9593impl LanguageServer for DjangoLanguageServer {
9694 async fn initialize ( & self , params : InitializeParams ) -> LspResult < InitializeResult > {
97- log_info ! ( "Initializing server..." ) ;
95+ tracing :: info !( "Initializing server..." ) ;
9896
9997 let session = Session :: new ( & params) ;
10098
@@ -142,7 +140,7 @@ impl LanguageServer for DjangoLanguageServer {
142140
143141 #[ allow( clippy:: too_many_lines) ]
144142 async fn initialized ( & self , _params : InitializedParams ) {
145- log_info ! ( "Server received initialized notification." ) ;
143+ tracing :: info !( "Server received initialized notification." ) ;
146144
147145 self . with_session_task ( |session_arc| async move {
148146 let project_path_and_venv = {
@@ -162,13 +160,13 @@ impl LanguageServer for DjangoLanguageServer {
162160 } ;
163161
164162 if let Some ( ( path_display, venv_path) ) = project_path_and_venv {
165- log_info ! (
163+ tracing :: info !(
166164 "Task: Starting initialization for project at: {}" ,
167165 path_display
168166 ) ;
169167
170168 if let Some ( ref path) = venv_path {
171- log_info ! ( "Using virtual environment from config: {}" , path) ;
169+ tracing :: info !( "Using virtual environment from config: {}" , path) ;
172170 }
173171
174172 let init_result = {
@@ -188,10 +186,10 @@ impl LanguageServer for DjangoLanguageServer {
188186
189187 match init_result {
190188 Ok ( ( ) ) => {
191- log_info ! ( "Task: Successfully initialized project: {}" , path_display) ;
189+ tracing :: info !( "Task: Successfully initialized project: {}" , path_display) ;
192190 }
193191 Err ( e) => {
194- log_error ! (
192+ tracing :: error !(
195193 "Task: Failed to initialize Django project at {}: {}" ,
196194 path_display,
197195 e
@@ -205,7 +203,7 @@ impl LanguageServer for DjangoLanguageServer {
205203 }
206204 }
207205 } else {
208- log_info ! ( "Task: No project instance found to initialize." ) ;
206+ tracing :: info !( "Task: No project instance found to initialize." ) ;
209207 }
210208 Ok ( ( ) )
211209 } )
@@ -217,7 +215,7 @@ impl LanguageServer for DjangoLanguageServer {
217215 }
218216
219217 async fn did_open ( & self , params : DidOpenTextDocumentParams ) {
220- log_info ! ( "Opened document: {:?}" , params. text_document. uri) ;
218+ tracing :: info !( "Opened document: {:?}" , params. text_document. uri) ;
221219
222220 self . with_session_mut ( |session| {
223221 let db = session. db ( ) ;
@@ -227,7 +225,7 @@ impl LanguageServer for DjangoLanguageServer {
227225 }
228226
229227 async fn did_change ( & self , params : DidChangeTextDocumentParams ) {
230- log_info ! ( "Changed document: {:?}" , params. text_document. uri) ;
228+ tracing :: info !( "Changed document: {:?}" , params. text_document. uri) ;
231229
232230 self . with_session_mut ( |session| {
233231 let db = session. db ( ) ;
@@ -237,7 +235,7 @@ impl LanguageServer for DjangoLanguageServer {
237235 }
238236
239237 async fn did_close ( & self , params : DidCloseTextDocumentParams ) {
240- log_info ! ( "Closed document: {:?}" , params. text_document. uri) ;
238+ tracing :: info !( "Closed document: {:?}" , params. text_document. uri) ;
241239
242240 self . with_session_mut ( |session| {
243241 session. documents_mut ( ) . handle_did_close ( & params) ;
@@ -265,7 +263,7 @@ impl LanguageServer for DjangoLanguageServer {
265263 }
266264
267265 async fn did_change_configuration ( & self , _params : DidChangeConfigurationParams ) {
268- log_info ! ( "Configuration change detected. Reloading settings..." ) ;
266+ tracing :: info !( "Configuration change detected. Reloading settings..." ) ;
269267
270268 let project_path = self
271269 . with_session ( |session| session. project ( ) . map ( |p| p. path ( ) . to_path_buf ( ) ) )
@@ -277,7 +275,7 @@ impl LanguageServer for DjangoLanguageServer {
277275 session. set_settings ( new_settings) ;
278276 }
279277 Err ( e) => {
280- log_error ! ( "Error loading settings: {}" , e) ;
278+ tracing :: error !( "Error loading settings: {}" , e) ;
281279 }
282280 } )
283281 . await ;
0 commit comments