fix handling of verbose
This commit is contained in:
parent
13c8d4e052
commit
dc6377b8bc
3 changed files with 52 additions and 53 deletions
|
@ -80,6 +80,7 @@ impl Message for LogMessage {
|
|||
|
||||
pub(super) struct TraceMessage {
|
||||
message: String,
|
||||
is_verbose: bool,
|
||||
}
|
||||
|
||||
impl AsRef<str> for TraceMessage {
|
||||
|
@ -89,7 +90,15 @@ impl AsRef<str> for TraceMessage {
|
|||
}
|
||||
|
||||
impl Message for TraceMessage {
|
||||
type Level = ();
|
||||
type Level = TraceValue;
|
||||
|
||||
fn should_include(&self, level: Self::Level) -> bool {
|
||||
match level {
|
||||
TraceValue::Off => false,
|
||||
TraceValue::Messages => !self.is_verbose,
|
||||
TraceValue::Verbose => true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct RpcMessage {
|
||||
|
@ -192,7 +201,7 @@ impl LogKind {
|
|||
fn from_server_log_type(log_type: &LanguageServerLogType) -> Self {
|
||||
match log_type {
|
||||
LanguageServerLogType::Log(_) => Self::Logs,
|
||||
LanguageServerLogType::Trace(_) => Self::Trace,
|
||||
LanguageServerLogType::Trace { .. } => Self::Trace,
|
||||
LanguageServerLogType::Rpc { .. } => Self::Rpc,
|
||||
}
|
||||
}
|
||||
|
@ -383,9 +392,13 @@ impl LogStore {
|
|||
project::LanguageServerLogType::Log(typ) => {
|
||||
log_store.add_language_server_log(*id, *typ, message, cx);
|
||||
}
|
||||
project::LanguageServerLogType::Trace(_) => {
|
||||
// todo! do something with trace level
|
||||
log_store.add_language_server_trace(*id, message, cx);
|
||||
project::LanguageServerLogType::Trace { verbose_info } => {
|
||||
log_store.add_language_server_trace(
|
||||
*id,
|
||||
message,
|
||||
verbose_info.clone(),
|
||||
cx,
|
||||
);
|
||||
}
|
||||
project::LanguageServerLogType::Rpc { received } => {
|
||||
let kind = if *received {
|
||||
|
@ -491,7 +504,7 @@ impl LogStore {
|
|||
let log_lines = &mut language_server_state.log_messages;
|
||||
let message = message.trim_end().to_string();
|
||||
if !store_logs {
|
||||
// Send all messages regardless of the visiblity in case of not storing, to notify the receiver anyway
|
||||
// Send all messages regardless of the visibility in case of not storing, to notify the receiver anyway
|
||||
cx.emit(Event::NewServerLogEntry {
|
||||
id,
|
||||
kind: LanguageServerLogType::Log(typ),
|
||||
|
@ -515,6 +528,7 @@ impl LogStore {
|
|||
&mut self,
|
||||
id: LanguageServerId,
|
||||
message: &str,
|
||||
verbose_info: Option<String>,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Option<()> {
|
||||
let store_logs = self.store_logs;
|
||||
|
@ -522,24 +536,33 @@ impl LogStore {
|
|||
|
||||
let log_lines = &mut language_server_state.trace_messages;
|
||||
if !store_logs {
|
||||
// Send all messages regardless of the visiblity in case of not storing, to notify the receiver anyway
|
||||
// Send all messages regardless of the visibility in case of not storing, to notify the receiver anyway
|
||||
cx.emit(Event::NewServerLogEntry {
|
||||
id,
|
||||
// todo! Ben, fix this here too!
|
||||
kind: LanguageServerLogType::Trace(project::lsp_store::TraceLevel::Verbose),
|
||||
kind: LanguageServerLogType::Trace { verbose_info },
|
||||
text: message.trim().to_string(),
|
||||
});
|
||||
} else if let Some(new_message) = Self::push_new_message(
|
||||
log_lines,
|
||||
TraceMessage {
|
||||
message: message.trim().to_string(),
|
||||
is_verbose: false,
|
||||
},
|
||||
(),
|
||||
TraceValue::Messages,
|
||||
) {
|
||||
if let Some(verbose_message) = verbose_info.as_ref() {
|
||||
Self::push_new_message(
|
||||
log_lines,
|
||||
TraceMessage {
|
||||
message: verbose_message.clone(),
|
||||
is_verbose: true,
|
||||
},
|
||||
TraceValue::Verbose,
|
||||
);
|
||||
}
|
||||
cx.emit(Event::NewServerLogEntry {
|
||||
id,
|
||||
// todo! Ben, fix this here too!
|
||||
kind: LanguageServerLogType::Trace(project::lsp_store::TraceLevel::Verbose),
|
||||
kind: LanguageServerLogType::Trace { verbose_info },
|
||||
text: new_message,
|
||||
});
|
||||
}
|
||||
|
@ -1115,11 +1138,17 @@ impl LspLogView {
|
|||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
let trace_level = self
|
||||
.log_store
|
||||
.update(cx, |this, _| {
|
||||
Some(this.get_language_server_state(server_id)?.trace_level)
|
||||
})
|
||||
.unwrap_or(TraceValue::Messages);
|
||||
let log_contents = self
|
||||
.log_store
|
||||
.read(cx)
|
||||
.server_trace(server_id)
|
||||
.map(|v| log_contents(v, ()));
|
||||
.map(|v| log_contents(v, trace_level));
|
||||
if let Some(log_contents) = log_contents {
|
||||
self.current_server_id = Some(server_id);
|
||||
self.active_entry_kind = LogKind::Trace;
|
||||
|
|
|
@ -977,13 +977,9 @@ impl LocalLspStore {
|
|||
this.update(&mut cx, |_, cx| {
|
||||
cx.emit(LspStoreEvent::LanguageServerLog(
|
||||
server_id,
|
||||
// todo! store verbose info on Verbose
|
||||
LanguageServerLogType::Trace(
|
||||
params
|
||||
.verbose
|
||||
.map(|_verbose_info| TraceLevel::Verbose)
|
||||
.unwrap_or(TraceLevel::Messages),
|
||||
),
|
||||
LanguageServerLogType::Trace {
|
||||
verbose_info: params.verbose,
|
||||
},
|
||||
params.message,
|
||||
));
|
||||
})
|
||||
|
@ -12684,17 +12680,10 @@ impl PartialEq for LanguageServerPromptRequest {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum TraceLevel {
|
||||
Off,
|
||||
Messages,
|
||||
Verbose,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub enum LanguageServerLogType {
|
||||
Log(MessageType),
|
||||
Trace(TraceLevel),
|
||||
Trace { verbose_info: Option<String> },
|
||||
Rpc { received: bool },
|
||||
}
|
||||
|
||||
|
@ -12717,15 +12706,9 @@ impl LanguageServerLogType {
|
|||
level: level as i32,
|
||||
})
|
||||
}
|
||||
Self::Trace(trace_level) => {
|
||||
use proto::trace_message;
|
||||
let level = match trace_level {
|
||||
TraceLevel::Off => trace_message::TraceLevel::Off,
|
||||
TraceLevel::Messages => trace_message::TraceLevel::Messages,
|
||||
TraceLevel::Verbose => trace_message::TraceLevel::Verbose,
|
||||
};
|
||||
Self::Trace { verbose_info } => {
|
||||
proto::language_server_log::LogType::Trace(proto::TraceMessage {
|
||||
level: level as i32,
|
||||
verbose_info: verbose_info.to_owned(),
|
||||
})
|
||||
}
|
||||
Self::Rpc { received } => {
|
||||
|
@ -12743,7 +12726,6 @@ impl LanguageServerLogType {
|
|||
pub fn from_proto(log_type: proto::language_server_log::LogType) -> Self {
|
||||
use proto::log_message::LogLevel;
|
||||
use proto::rpc_message;
|
||||
use proto::trace_message;
|
||||
match log_type {
|
||||
proto::language_server_log::LogType::Log(message_type) => Self::Log(
|
||||
match LogLevel::from_i32(message_type.level).unwrap_or(LogLevel::Log) {
|
||||
|
@ -12753,15 +12735,9 @@ impl LanguageServerLogType {
|
|||
LogLevel::Log => MessageType::LOG,
|
||||
},
|
||||
),
|
||||
proto::language_server_log::LogType::Trace(trace) => Self::Trace(
|
||||
match trace_message::TraceLevel::from_i32(trace.level)
|
||||
.unwrap_or(trace_message::TraceLevel::Messages)
|
||||
{
|
||||
trace_message::TraceLevel::Off => TraceLevel::Off,
|
||||
trace_message::TraceLevel::Messages => TraceLevel::Messages,
|
||||
trace_message::TraceLevel::Verbose => TraceLevel::Verbose,
|
||||
},
|
||||
),
|
||||
proto::language_server_log::LogType::Trace(trace_message) => Self::Trace {
|
||||
verbose_info: trace_message.verbose_info,
|
||||
},
|
||||
proto::language_server_log::LogType::Rpc(message) => Self::Rpc {
|
||||
received: match rpc_message::Kind::from_i32(message.kind)
|
||||
.unwrap_or(rpc_message::Kind::Received)
|
||||
|
|
|
@ -630,13 +630,7 @@ message LogMessage {
|
|||
}
|
||||
|
||||
message TraceMessage {
|
||||
TraceLevel level = 1;
|
||||
|
||||
enum TraceLevel {
|
||||
OFF = 0;
|
||||
MESSAGES = 1;
|
||||
VERBOSE = 2;
|
||||
}
|
||||
optional string verbose_info = 1;
|
||||
}
|
||||
|
||||
message RpcMessage {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue