pub struct Logger { /* private fields */ }Expand description
A logger bound to one LogCtx. Cheap to clone (clones the ctx); writes
serialize behind a process-global stderr mutex so lines never interleave.
Implementations§
Source§impl Logger
impl Logger
pub fn new(ctx: LogCtx, min: Level) -> Self
Sourcepub fn with_content(self, on: bool) -> Self
pub fn with_content(self, on: bool) -> Self
Opt into content capture: callers that log tool args/results consult
Logger::content_capture first. Off by default, so args and results
are recorded as lengths only unless an operator asks for the bodies.
Sourcepub fn content_capture(&self) -> bool
pub fn content_capture(&self) -> bool
Whether this logger may record tool args/results (not just lengths).
pub fn ctx(&self) -> &LogCtx
Sourcepub fn event(&self, level: Level, event: &str, fields: Value)
pub fn event(&self, level: Level, event: &str, fields: Value)
Emit one event. fields should be a JSON object; its keys are merged
after the canonical fields (event-specific data). Non-object fields
is ignored. Below min level: dropped cheaply.
pub fn info(&self, event: &str, fields: Value)
pub fn warn(&self, event: &str, fields: Value)
pub fn error(&self, event: &str, fields: Value)
pub fn debug(&self, event: &str, fields: Value)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Logger
impl RefUnwindSafe for Logger
impl Send for Logger
impl Sync for Logger
impl Unpin for Logger
impl UnsafeUnpin for Logger
impl UnwindSafe for Logger
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
Mutably borrows from an owned value. Read more