Skip to content

Commit

Permalink
Implement logging for debug adapter clients (#45)
Browse files Browse the repository at this point in the history
* Implement RPC logging for debug adapter clients

* Implement server logs for debugger servers

* This cleans up the way we pass through the input and output readers for logging. So not each debug adapters have to map the AdapterLogIO fields.  I also removed some specific when has logs from the client, because the client is not responsible for that.  Removed an not needed/duplicated dependency  Fix formatting & clippy

This cleans up the way we pass through the input and output readers for logging. So not each debug adapters have to map the AdapterLogIO fields.

I also removed some specific when has logs from the client, because the client is not responsible for that.

Removed an not needed/duplicated dependency

Fix formatting & clippy

* Implement `has_adapter_logs` for each transport impl

* Make adapter stdout logging work

* Add conditional render for adapter log back

* Oops forgot to pipe the output

* Always enable rpc messages

Previously, RPC messages were only stored when explicitly enabled, which occurred after the client was already running. This approach prevented debugging of requests sent during the initial connection period. By always enabling RPC messages, we ensure that all requests, including those during the connection phase, are captured and available for debugging purposes.

This could help use debug when someone has troble getting a debug starting. This improvement could be particularly helpful in debugging scenarios where users encounter issues during the initial connection or startup phase of their debugging sessions.

---------

Co-authored-by: Remco Smits <djsmits12@gmail.com>
Co-authored-by: Anthony Eid <hello@anthonyeid.me>
  • Loading branch information
3 people authored Oct 21, 2024
1 parent 30a4c84 commit 43ea3b4
Show file tree
Hide file tree
Showing 13 changed files with 957 additions and 30 deletions.
17 changes: 17 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ members = [
#

"tooling/xtask",
"crates/debugger_tools",
]
default-members = ["crates/zed"]

Expand Down Expand Up @@ -207,6 +208,7 @@ dap = { path = "crates/dap" }
dap_adapters = { path = "crates/dap_adapters" }
db = { path = "crates/db" }
debugger_ui = { path = "crates/debugger_ui" }
debugger_tools = { path = "crates/debugger_tools" }
dev_server_projects = { path = "crates/dev_server_projects" }
diagnostics = { path = "crates/diagnostics" }
editor = { path = "crates/editor" }
Expand Down
2 changes: 2 additions & 0 deletions crates/dap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ gpui.workspace = true
http_client.workspace = true
log.workspace = true
node_runtime.workspace = true
parking_lot.workspace = true
schemars.workspace = true
serde.workspace = true
serde_json.workspace = true
settings.workspace = true
smallvec.workspace = true
smol.workspace = true
task.workspace = true
1 change: 0 additions & 1 deletion crates/dap/src/adapters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use http_client::HttpClient;
use node_runtime::NodeRuntime;
use serde_json::Value;
use std::{collections::HashMap, ffi::OsString, path::Path, sync::Arc};

use task::DebugAdapterConfig;

pub trait DapDelegate {
Expand Down
14 changes: 13 additions & 1 deletion crates/dap/src/client.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use crate::{
adapters::{DebugAdapter, DebugAdapterBinary},
transport::TransportDelegate,
transport::{IoKind, LogKind, TransportDelegate},
};
use anyhow::{anyhow, Result};

use dap_types::{
messages::{Message, Response},
requests::Request,
Expand Down Expand Up @@ -163,4 +164,15 @@ impl DebugAdapterClient {
pub async fn shutdown(&self) -> Result<()> {
self.transport_delegate.shutdown().await
}

pub fn has_adapter_logs(&self) -> bool {
self.transport_delegate.has_adapter_logs()
}

pub fn add_log_handler<F>(&self, f: F, kind: LogKind)
where
F: 'static + Send + FnMut(IoKind, &str),
{
self.transport_delegate.add_log_handler(f, kind);
}
}
Loading

0 comments on commit 43ea3b4

Please sign in to comment.