feat: clean up logs (#1473)

This commit is contained in:
Myriad-Dreamin 2025-03-10 11:41:41 +08:00 committed by GitHub
parent 2639dbd49e
commit be1bf802c0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 14 additions and 14 deletions

View file

@ -297,7 +297,7 @@ impl LspClient {
let mut req_queue = self.req_queue.lock();
let method = request.method.clone();
let req_id = request.id.clone();
self.start_request(&req_id, &method, received_at);
self.start_request(&req_id, &method);
req_queue.incoming.register(req_id, (method, received_at));
}
@ -378,8 +378,8 @@ impl LspClient {
}
impl LspClient {
fn start_request(&self, req_id: &RequestId, method: &str, received_at: Instant) {
log::info!("handling {method} - ({req_id}) at {received_at:0.2?}");
fn start_request(&self, req_id: &RequestId, method: &str) {
log::info!("handling {method} - ({req_id})");
}
fn stop_request(&self, req_id: &RequestId, method: &str, received_at: Instant) {
@ -387,16 +387,16 @@ impl LspClient {
log::info!("handled {method} - ({req_id}) in {duration:0.2?}");
}
fn start_notification(&self, method: &str, received_at: Instant) {
log::info!("notifying {method} at {received_at:0.2?}");
fn start_notification(&self, method: &str) {
log::info!("notifying {method}");
}
fn stop_notification(&self, method: &str, received_at: Instant, result: LspResult<()>) {
let request_duration = received_at.elapsed();
if let Err(err) = result {
log::error!("notifying {method} failed in {request_duration:0.2?}: {err:?}");
log::error!("notify {method} failed in {request_duration:0.2?}: {err:?}");
} else {
log::info!("notifying {method} succeeded in {request_duration:0.2?}");
log::info!("notify {method} succeeded in {request_duration:0.2?}");
}
}
}
@ -884,7 +884,7 @@ where
/// Handles an incoming notification.
fn on_notification(&mut self, received_at: Instant, not: Notification) -> anyhow::Result<()> {
self.client.start_notification(&not.method, received_at);
self.client.start_notification(&not.method);
let handle = |s, Notification { method, params }: Notification| {
let Some(handler) = self.notifications.get(method.as_str()) else {
log::warn!("unhandled notification: {method}");

View file

@ -103,7 +103,7 @@ impl LspWorldExt for tinymist_project::LspWorld {
fn uri_for_id(&self, fid: FileId) -> Result<Url, FileError> {
let res = path_res_to_url(self.path_for_id(fid)?);
log::info!("uri_for_id: {fid:?} -> {res:?}");
crate::log_debug_ct!("uri_for_id: {fid:?} -> {res:?}");
res.map_err(|err| FileError::Other(Some(eco_format!("convert to url: {err:?}"))))
}

View file

@ -15,7 +15,7 @@ use crate::*;
impl ServerState {
/// Updates a set of source files.
fn update_sources(&mut self, files: FileChangeSet) -> Result<()> {
log::info!("update source: {files:?}");
log::trace!("update source: {files:?}");
let intr = Interrupt::Memory(MemoryEvent::Update(files.clone()));
self.project.interrupt(intr);
@ -25,7 +25,7 @@ impl ServerState {
/// Creates a new source file.
pub fn create_source(&mut self, path: ImmutPath, content: String) -> Result<()> {
log::info!("create source: {path:?}");
log::trace!("create source: {path:?}");
self.memory_changes
.insert(path.clone(), Source::detached(content.clone()));
@ -40,7 +40,7 @@ impl ServerState {
/// Removes a source file.
pub fn remove_source(&mut self, path: ImmutPath) -> Result<()> {
self.memory_changes.remove(&path);
log::info!("remove source: {path:?}");
log::trace!("remove source: {path:?}");
// todo: is it safe to believe that the path is normalized?
let files = FileChangeSet::new_removes(vec![path]);

View file

@ -80,7 +80,7 @@ impl ServerState {
/// LSP Document Synchronization
impl ServerState {
pub(crate) fn did_open(&mut self, params: DidOpenTextDocumentParams) -> LspResult<()> {
log::info!("did open {:?}", params.text_document.uri);
log::info!("did open {}", params.text_document.uri);
let path: ImmutPath = as_path_(params.text_document.uri).as_path().into();
let text = params.text_document.text;

View file

@ -116,7 +116,7 @@ pub fn lsp_main(args: LspArgs) -> Result<()> {
.map(|e| e.splitn(2, ":").map(|e| e.trim()).collect::<Vec<_>>())
.collect::<Vec<_>>();
log::info!("tinymist version information: {pairs:?}");
log::info!("starting Language server: {args:#?}");
log::info!("starting language server: {args:?}");
let is_replay = !args.mirror.replay.is_empty();
with_stdio_transport(args.mirror.clone(), |conn| {