From c424e5c8c144128418971b1ea175d0ee379751e4 Mon Sep 17 00:00:00 2001 From: Emmanuel Bastien Date: Fri, 12 Jan 2024 11:00:32 +0100 Subject: [PATCH] feat: stderr logging for lsp client --- oal-client/src/bin/oal-lsp.rs | 12 ++++++++++-- oal-client/src/lsp/mod.rs | 2 ++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/oal-client/src/bin/oal-lsp.rs b/oal-client/src/bin/oal-lsp.rs index a4e1253..1f53c46 100644 --- a/oal-client/src/bin/oal-lsp.rs +++ b/oal-client/src/bin/oal-lsp.rs @@ -1,5 +1,6 @@ use anyhow::anyhow; use crossbeam_channel::select; +use log::info; use lsp_server::{Connection, Message, Notification}; use lsp_types::notification::{ DidChangeTextDocument, DidChangeWorkspaceFolders, DidCloseTextDocument, DidOpenTextDocument, @@ -19,8 +20,15 @@ use std::collections::HashMap; use std::time::Duration; fn main() -> anyhow::Result<()> { + stderrlog::new() + .quiet(false) + .verbosity(log::Level::Info) + .timestamp(stderrlog::Timestamp::Second) + .init() + .unwrap(); + // Note that we must have our logging only write out to stderr. - eprintln!("starting Oxlip API Language server"); + info!("starting Oxlip API Language server"); // Create the transport. Includes the stdio (stdin and stdout) versions but this could // also be implemented to use sockets or HTTP. @@ -84,7 +92,7 @@ fn main() -> anyhow::Result<()> { threads.join()?; // Shut down gracefully. - eprintln!("shutting down Oxlip API Language server"); + info!("shutting down Oxlip API Language server"); Ok(()) } diff --git a/oal-client/src/lsp/mod.rs b/oal-client/src/lsp/mod.rs index fee4f12..37f7f74 100644 --- a/oal-client/src/lsp/mod.rs +++ b/oal-client/src/lsp/mod.rs @@ -9,6 +9,7 @@ mod tests; use crate::config::Config; use crate::{DefaultFileSystem, FileSystem}; use anyhow::anyhow; +use log::debug; use lsp_types::{ Diagnostic, DidChangeTextDocumentParams, DidCloseTextDocumentParams, DidOpenTextDocumentParams, }; @@ -68,6 +69,7 @@ impl Folder { self.mods = None; self.spec = None; if let Ok(main) = self.config.main() { + debug!("evaluating {}", main); if let Ok(mods) = ws.load(&main) { self.spec = ws.eval(&mods).ok(); self.mods = Some(mods);