pub struct StructuredLogger { /* private fields */ }Expand description
Main structured logger
Implementations§
Source§impl StructuredLogger
impl StructuredLogger
Sourcepub fn new(config: &ObservabilityConfig) -> Result<Self>
pub fn new(config: &ObservabilityConfig) -> Result<Self>
Create a new structured logger
Sourcepub async fn initialize(&self) -> Result<()>
pub async fn initialize(&self) -> Result<()>
Initialize the structured logger
Sourcepub fn log_with_context(
&self,
level: LogLevel,
message: &str,
trace_context: &TraceContext,
)
pub fn log_with_context( &self, level: LogLevel, message: &str, trace_context: &TraceContext, )
Log a message with full context
Sourcepub fn log_with_correlation(
&self,
level: LogLevel,
message: &str,
context: &CorrelationContext,
)
pub fn log_with_correlation( &self, level: LogLevel, message: &str, context: &CorrelationContext, )
Log with correlation context
Sourcepub async fn get_recent_entries(&self, limit: usize) -> Vec<LogEntry>
pub async fn get_recent_entries(&self, limit: usize) -> Vec<LogEntry>
Get recent log entries
Sourcepub async fn clear_entries(&self)
pub async fn clear_entries(&self)
Clear stored log entries
Sourcepub async fn get_all_entries(&self) -> Vec<LogEntry>
pub async fn get_all_entries(&self) -> Vec<LogEntry>
Get all log entries
Sourcepub async fn export_logs(&self, file_path: &str) -> Result<()>
pub async fn export_logs(&self, file_path: &str) -> Result<()>
Export logs to JSON file
Trait Implementations§
Auto Trait Implementations§
impl Freeze for StructuredLogger
impl !RefUnwindSafe for StructuredLogger
impl Send for StructuredLogger
impl Sync for StructuredLogger
impl Unpin for StructuredLogger
impl !UnwindSafe for StructuredLogger
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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>
Converts
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>
Converts
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