@@ -25,8 +25,7 @@ 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;
28+
3029use crate :: queue:: Queue ;
3130use crate :: session:: Session ;
3231
@@ -58,7 +57,7 @@ impl DjangoLanguageServer {
5857 if let Some ( s) = & * session {
5958 f ( s)
6059 } else {
61- log_error ! ( "Attempted to access session before initialization" ) ;
60+ tracing :: error !( "Attempted to access session before initialization" ) ;
6261 R :: default ( )
6362 }
6463 }
@@ -72,7 +71,7 @@ impl DjangoLanguageServer {
7271 if let Some ( s) = & mut * session {
7372 f ( s)
7473 } else {
75- log_error ! ( "Attempted to access session before initialization" ) ;
74+ tracing :: error !( "Attempted to access session before initialization" ) ;
7675 R :: default ( )
7776 }
7877 }
@@ -85,16 +84,16 @@ impl DjangoLanguageServer {
8584 let session_arc = Arc :: clone ( & self . session ) ;
8685
8786 if let Err ( e) = self . queue . submit ( async move { f ( session_arc) . await } ) . await {
88- log_error ! ( "Failed to submit task: {}" , e) ;
87+ tracing :: error !( "Failed to submit task: {}" , e) ;
8988 } else {
90- log_info ! ( "Task submitted successfully" ) ;
89+ tracing :: info !( "Task submitted successfully" ) ;
9190 }
9291 }
9392}
9493
9594impl LanguageServer for DjangoLanguageServer {
9695 async fn initialize ( & self , params : InitializeParams ) -> LspResult < InitializeResult > {
97- log_info ! ( "Initializing server..." ) ;
96+ tracing :: info !( "Initializing server..." ) ;
9897
9998 let session = Session :: new ( & params) ;
10099
@@ -142,7 +141,7 @@ impl LanguageServer for DjangoLanguageServer {
142141
143142 #[ allow( clippy:: too_many_lines) ]
144143 async fn initialized ( & self , _params : InitializedParams ) {
145- log_info ! ( "Server received initialized notification." ) ;
144+ tracing :: info !( "Server received initialized notification." ) ;
146145
147146 self . with_session_task ( |session_arc| async move {
148147 let project_path_and_venv = {
@@ -162,13 +161,13 @@ impl LanguageServer for DjangoLanguageServer {
162161 } ;
163162
164163 if let Some ( ( path_display, venv_path) ) = project_path_and_venv {
165- log_info ! (
164+ tracing :: info !(
166165 "Task: Starting initialization for project at: {}" ,
167166 path_display
168167 ) ;
169168
170169 if let Some ( ref path) = venv_path {
171- log_info ! ( "Using virtual environment from config: {}" , path) ;
170+ tracing :: info !( "Using virtual environment from config: {}" , path) ;
172171 }
173172
174173 let init_result = {
@@ -188,10 +187,10 @@ impl LanguageServer for DjangoLanguageServer {
188187
189188 match init_result {
190189 Ok ( ( ) ) => {
191- log_info ! ( "Task: Successfully initialized project: {}" , path_display) ;
190+ tracing :: info !( "Task: Successfully initialized project: {}" , path_display) ;
192191 }
193192 Err ( e) => {
194- log_error ! (
193+ tracing :: error !(
195194 "Task: Failed to initialize Django project at {}: {}" ,
196195 path_display,
197196 e
@@ -205,7 +204,7 @@ impl LanguageServer for DjangoLanguageServer {
205204 }
206205 }
207206 } else {
208- log_info ! ( "Task: No project instance found to initialize." ) ;
207+ tracing :: info !( "Task: No project instance found to initialize." ) ;
209208 }
210209 Ok ( ( ) )
211210 } )
@@ -217,7 +216,7 @@ impl LanguageServer for DjangoLanguageServer {
217216 }
218217
219218 async fn did_open ( & self , params : DidOpenTextDocumentParams ) {
220- log_info ! ( "Opened document: {:?}" , params. text_document. uri) ;
219+ tracing :: info !( "Opened document: {:?}" , params. text_document. uri) ;
221220
222221 self . with_session_mut ( |session| {
223222 let db = session. db ( ) ;
@@ -227,7 +226,7 @@ impl LanguageServer for DjangoLanguageServer {
227226 }
228227
229228 async fn did_change ( & self , params : DidChangeTextDocumentParams ) {
230- log_info ! ( "Changed document: {:?}" , params. text_document. uri) ;
229+ tracing :: info !( "Changed document: {:?}" , params. text_document. uri) ;
231230
232231 self . with_session_mut ( |session| {
233232 let db = session. db ( ) ;
@@ -237,7 +236,7 @@ impl LanguageServer for DjangoLanguageServer {
237236 }
238237
239238 async fn did_close ( & self , params : DidCloseTextDocumentParams ) {
240- log_info ! ( "Closed document: {:?}" , params. text_document. uri) ;
239+ tracing :: info !( "Closed document: {:?}" , params. text_document. uri) ;
241240
242241 self . with_session_mut ( |session| {
243242 session. documents_mut ( ) . handle_did_close ( & params) ;
@@ -265,7 +264,7 @@ impl LanguageServer for DjangoLanguageServer {
265264 }
266265
267266 async fn did_change_configuration ( & self , _params : DidChangeConfigurationParams ) {
268- log_info ! ( "Configuration change detected. Reloading settings..." ) ;
267+ tracing :: info !( "Configuration change detected. Reloading settings..." ) ;
269268
270269 let project_path = self
271270 . with_session ( |session| session. project ( ) . map ( |p| p. path ( ) . to_path_buf ( ) ) )
@@ -277,7 +276,7 @@ impl LanguageServer for DjangoLanguageServer {
277276 session. set_settings ( new_settings) ;
278277 }
279278 Err ( e) => {
280- log_error ! ( "Error loading settings: {}" , e) ;
279+ tracing :: error !( "Error loading settings: {}" , e) ;
281280 }
282281 } )
283282 . await ;
0 commit comments