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 {
|
pub(super) struct TraceMessage {
|
||||||
message: String,
|
message: String,
|
||||||
|
is_verbose: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsRef<str> for TraceMessage {
|
impl AsRef<str> for TraceMessage {
|
||||||
|
@ -89,7 +90,15 @@ impl AsRef<str> for TraceMessage {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Message 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 {
|
struct RpcMessage {
|
||||||
|
@ -192,7 +201,7 @@ impl LogKind {
|
||||||
fn from_server_log_type(log_type: &LanguageServerLogType) -> Self {
|
fn from_server_log_type(log_type: &LanguageServerLogType) -> Self {
|
||||||
match log_type {
|
match log_type {
|
||||||
LanguageServerLogType::Log(_) => Self::Logs,
|
LanguageServerLogType::Log(_) => Self::Logs,
|
||||||
LanguageServerLogType::Trace(_) => Self::Trace,
|
LanguageServerLogType::Trace { .. } => Self::Trace,
|
||||||
LanguageServerLogType::Rpc { .. } => Self::Rpc,
|
LanguageServerLogType::Rpc { .. } => Self::Rpc,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -383,9 +392,13 @@ impl LogStore {
|
||||||
project::LanguageServerLogType::Log(typ) => {
|
project::LanguageServerLogType::Log(typ) => {
|
||||||
log_store.add_language_server_log(*id, *typ, message, cx);
|
log_store.add_language_server_log(*id, *typ, message, cx);
|
||||||
}
|
}
|
||||||
project::LanguageServerLogType::Trace(_) => {
|
project::LanguageServerLogType::Trace { verbose_info } => {
|
||||||
// todo! do something with trace level
|
log_store.add_language_server_trace(
|
||||||
log_store.add_language_server_trace(*id, message, cx);
|
*id,
|
||||||
|
message,
|
||||||
|
verbose_info.clone(),
|
||||||
|
cx,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
project::LanguageServerLogType::Rpc { received } => {
|
project::LanguageServerLogType::Rpc { received } => {
|
||||||
let kind = if *received {
|
let kind = if *received {
|
||||||
|
@ -491,7 +504,7 @@ impl LogStore {
|
||||||
let log_lines = &mut language_server_state.log_messages;
|
let log_lines = &mut language_server_state.log_messages;
|
||||||
let message = message.trim_end().to_string();
|
let message = message.trim_end().to_string();
|
||||||
if !store_logs {
|
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 {
|
cx.emit(Event::NewServerLogEntry {
|
||||||
id,
|
id,
|
||||||
kind: LanguageServerLogType::Log(typ),
|
kind: LanguageServerLogType::Log(typ),
|
||||||
|
@ -515,6 +528,7 @@ impl LogStore {
|
||||||
&mut self,
|
&mut self,
|
||||||
id: LanguageServerId,
|
id: LanguageServerId,
|
||||||
message: &str,
|
message: &str,
|
||||||
|
verbose_info: Option<String>,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) -> Option<()> {
|
) -> Option<()> {
|
||||||
let store_logs = self.store_logs;
|
let store_logs = self.store_logs;
|
||||||
|
@ -522,24 +536,33 @@ impl LogStore {
|
||||||
|
|
||||||
let log_lines = &mut language_server_state.trace_messages;
|
let log_lines = &mut language_server_state.trace_messages;
|
||||||
if !store_logs {
|
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 {
|
cx.emit(Event::NewServerLogEntry {
|
||||||
id,
|
id,
|
||||||
// todo! Ben, fix this here too!
|
kind: LanguageServerLogType::Trace { verbose_info },
|
||||||
kind: LanguageServerLogType::Trace(project::lsp_store::TraceLevel::Verbose),
|
|
||||||
text: message.trim().to_string(),
|
text: message.trim().to_string(),
|
||||||
});
|
});
|
||||||
} else if let Some(new_message) = Self::push_new_message(
|
} else if let Some(new_message) = Self::push_new_message(
|
||||||
log_lines,
|
log_lines,
|
||||||
TraceMessage {
|
TraceMessage {
|
||||||
message: message.trim().to_string(),
|
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 {
|
cx.emit(Event::NewServerLogEntry {
|
||||||
id,
|
id,
|
||||||
// todo! Ben, fix this here too!
|
kind: LanguageServerLogType::Trace { verbose_info },
|
||||||
kind: LanguageServerLogType::Trace(project::lsp_store::TraceLevel::Verbose),
|
|
||||||
text: new_message,
|
text: new_message,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1115,11 +1138,17 @@ impl LspLogView {
|
||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
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
|
let log_contents = self
|
||||||
.log_store
|
.log_store
|
||||||
.read(cx)
|
.read(cx)
|
||||||
.server_trace(server_id)
|
.server_trace(server_id)
|
||||||
.map(|v| log_contents(v, ()));
|
.map(|v| log_contents(v, trace_level));
|
||||||
if let Some(log_contents) = log_contents {
|
if let Some(log_contents) = log_contents {
|
||||||
self.current_server_id = Some(server_id);
|
self.current_server_id = Some(server_id);
|
||||||
self.active_entry_kind = LogKind::Trace;
|
self.active_entry_kind = LogKind::Trace;
|
||||||
|
|
|
@ -977,13 +977,9 @@ impl LocalLspStore {
|
||||||
this.update(&mut cx, |_, cx| {
|
this.update(&mut cx, |_, cx| {
|
||||||
cx.emit(LspStoreEvent::LanguageServerLog(
|
cx.emit(LspStoreEvent::LanguageServerLog(
|
||||||
server_id,
|
server_id,
|
||||||
// todo! store verbose info on Verbose
|
LanguageServerLogType::Trace {
|
||||||
LanguageServerLogType::Trace(
|
verbose_info: params.verbose,
|
||||||
params
|
},
|
||||||
.verbose
|
|
||||||
.map(|_verbose_info| TraceLevel::Verbose)
|
|
||||||
.unwrap_or(TraceLevel::Messages),
|
|
||||||
),
|
|
||||||
params.message,
|
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)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
pub enum LanguageServerLogType {
|
pub enum LanguageServerLogType {
|
||||||
Log(MessageType),
|
Log(MessageType),
|
||||||
Trace(TraceLevel),
|
Trace { verbose_info: Option<String> },
|
||||||
Rpc { received: bool },
|
Rpc { received: bool },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12717,15 +12706,9 @@ impl LanguageServerLogType {
|
||||||
level: level as i32,
|
level: level as i32,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
Self::Trace(trace_level) => {
|
Self::Trace { verbose_info } => {
|
||||||
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,
|
|
||||||
};
|
|
||||||
proto::language_server_log::LogType::Trace(proto::TraceMessage {
|
proto::language_server_log::LogType::Trace(proto::TraceMessage {
|
||||||
level: level as i32,
|
verbose_info: verbose_info.to_owned(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
Self::Rpc { received } => {
|
Self::Rpc { received } => {
|
||||||
|
@ -12743,7 +12726,6 @@ impl LanguageServerLogType {
|
||||||
pub fn from_proto(log_type: proto::language_server_log::LogType) -> Self {
|
pub fn from_proto(log_type: proto::language_server_log::LogType) -> Self {
|
||||||
use proto::log_message::LogLevel;
|
use proto::log_message::LogLevel;
|
||||||
use proto::rpc_message;
|
use proto::rpc_message;
|
||||||
use proto::trace_message;
|
|
||||||
match log_type {
|
match log_type {
|
||||||
proto::language_server_log::LogType::Log(message_type) => Self::Log(
|
proto::language_server_log::LogType::Log(message_type) => Self::Log(
|
||||||
match LogLevel::from_i32(message_type.level).unwrap_or(LogLevel::Log) {
|
match LogLevel::from_i32(message_type.level).unwrap_or(LogLevel::Log) {
|
||||||
|
@ -12753,15 +12735,9 @@ impl LanguageServerLogType {
|
||||||
LogLevel::Log => MessageType::LOG,
|
LogLevel::Log => MessageType::LOG,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
proto::language_server_log::LogType::Trace(trace) => Self::Trace(
|
proto::language_server_log::LogType::Trace(trace_message) => Self::Trace {
|
||||||
match trace_message::TraceLevel::from_i32(trace.level)
|
verbose_info: trace_message.verbose_info,
|
||||||
.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::Rpc(message) => Self::Rpc {
|
proto::language_server_log::LogType::Rpc(message) => Self::Rpc {
|
||||||
received: match rpc_message::Kind::from_i32(message.kind)
|
received: match rpc_message::Kind::from_i32(message.kind)
|
||||||
.unwrap_or(rpc_message::Kind::Received)
|
.unwrap_or(rpc_message::Kind::Received)
|
||||||
|
|
|
@ -630,13 +630,7 @@ message LogMessage {
|
||||||
}
|
}
|
||||||
|
|
||||||
message TraceMessage {
|
message TraceMessage {
|
||||||
TraceLevel level = 1;
|
optional string verbose_info = 1;
|
||||||
|
|
||||||
enum TraceLevel {
|
|
||||||
OFF = 0;
|
|
||||||
MESSAGES = 1;
|
|
||||||
VERBOSE = 2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message RpcMessage {
|
message RpcMessage {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue