Skip to content

Commit

Permalink
feat: stderr logging for lsp client
Browse files Browse the repository at this point in the history
  • Loading branch information
ebastien committed Jan 12, 2024
1 parent 5f046d9 commit 6391afc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 10 additions & 2 deletions oal-client/src/bin/oal-lsp.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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.
Expand Down Expand Up @@ -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(())
}

Expand Down
2 changes: 2 additions & 0 deletions oal-client/src/lsp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 6391afc

Please sign in to comment.