pub struct LspLogger { /* private fields */ }Expand description
Producer-side log facade. One per LSP subsystem; each actor
gets a clone (cheap – internal state is Arc<Mutex<...>>).
Cheap-by-design: append is O(1) amortized, level gating is
one HashMap lookup, trace gating is one HashSet lookup.
Logging is not a hot path – per-keystroke cost is the
didChange encode + send, not the log emission.
Implementations§
Source§impl LspLogger
impl LspLogger
Sourcepub fn new(default_min_level: LogLevel, default_capacity: usize) -> Self
pub fn new(default_min_level: LogLevel, default_capacity: usize) -> Self
Construct a logger with the given default min level and
default per-server ring capacity (e.g. LogLevel::Info,
10_000). Conservative defaults: Info filters out trace
noise; 10k records ≈ a few MB of memory at most.
Sourcepub fn set_event_publisher(&self, publisher: LogEventPublisher)
pub fn set_event_publisher(&self, publisher: LogEventPublisher)
Install / replace the event publisher. Subsequent log
calls fire the closure with LspLogPushed after the
record lands in its ring. The App wires this at boot so
the runtime event bus sees every append; subscribers
(live log views) drain the bus on tick.
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Sensible defaults: Info level, 10k records / ring.
Sourcepub fn log(
&self,
instance: Option<&InstanceKey>,
level: LogLevel,
source: LogSource,
message: impl Into<String>,
)
pub fn log( &self, instance: Option<&InstanceKey>, level: LogLevel, source: LogSource, message: impl Into<String>, )
Append a record. Gated by per-instance min level (or the
default). Records with instance = None route to the
subsystem-wide ring (*lsp*) and use the default min level.
Trace-level records are additionally gated by the
per-instance trace toggle.
Sourcepub fn is_tracing(&self, instance: &InstanceKey) -> bool
pub fn is_tracing(&self, instance: &InstanceKey) -> bool
True iff trace mode is enabled for the instance. Cheap; the trace interceptors call this once per message and short-circuit the record build when false.
Sourcepub fn enable_trace(&self, instance: InstanceKey)
pub fn enable_trace(&self, instance: InstanceKey)
Enable JSON-RPC trace for an instance. Trace records start landing in the per-instance ring on the next emission.
Sourcepub fn disable_trace(&self, instance: &InstanceKey)
pub fn disable_trace(&self, instance: &InstanceKey)
Disable JSON-RPC trace for an instance.
Sourcepub fn toggle_trace(&self, instance: InstanceKey) -> bool
pub fn toggle_trace(&self, instance: InstanceKey) -> bool
Toggle JSON-RPC trace for an instance; returns the new state (true = on).
Sourcepub fn set_instance_level(&self, instance: InstanceKey, level: Option<LogLevel>)
pub fn set_instance_level(&self, instance: InstanceKey, level: Option<LogLevel>)
Set per-instance min level. None removes the override
and reverts to the default.
Sourcepub fn set_default_level(&self, level: LogLevel)
pub fn set_default_level(&self, level: LogLevel)
Set the default min level (applies to subsystem-wide records and to instances without an override).
Sourcepub fn set_default_capacity(&self, capacity: usize)
pub fn set_default_capacity(&self, capacity: usize)
Set the default ring capacity. Existing rings are resized; future per-instance rings inherit the new value.
Sourcepub fn snapshot_global(&self) -> Vec<LogRecord>
pub fn snapshot_global(&self) -> Vec<LogRecord>
Snapshot the subsystem-wide ring. Used by the *lsp*
buffer view to populate its body.
Sourcepub fn snapshot_instance(&self, instance: &InstanceKey) -> Vec<LogRecord>
pub fn snapshot_instance(&self, instance: &InstanceKey) -> Vec<LogRecord>
Snapshot an instance’s ring (empty if the instance has never logged anything).
Sourcepub fn known_instances(&self) -> Vec<InstanceKey>
pub fn known_instances(&self) -> Vec<InstanceKey>
List every instance with a per-instance ring. Useful for
:lsp-status and the *lsp* buffer’s “servers” header.
Sourcepub fn clear_global(&self)
pub fn clear_global(&self)
Drop the subsystem-wide ring’s contents.
Sourcepub fn clear_instance(&self, instance: &InstanceKey)
pub fn clear_instance(&self, instance: &InstanceKey)
Drop an instance’s ring contents.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LspLogger
impl RefUnwindSafe for LspLogger
impl Send for LspLogger
impl Sync for LspLogger
impl Unpin for LspLogger
impl UnsafeUnpin for LspLogger
impl UnwindSafe for LspLogger
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more