Struct StructuredLogger
pub struct StructuredLogger {
config: RwLock<RawRwLock, LogConfig>,
context: RwLock<RawRwLock, TraceContext>,
log_count: AtomicU64,
error_count: AtomicU64,
enabled: AtomicBool,
start_time: Instant,
sinks: RwLock<RawRwLock, Vec<Arc<dyn LogSink>>>,
}Expand description
Structured logger with trace correlation.
Fields§
§config: RwLock<RawRwLock, LogConfig>§context: RwLock<RawRwLock, TraceContext>§log_count: AtomicU64§error_count: AtomicU64§enabled: AtomicBool§start_time: Instant§sinks: RwLock<RawRwLock, Vec<Arc<dyn LogSink>>>Implementations§
§impl StructuredLogger
impl StructuredLogger
pub fn new(config: LogConfig) -> StructuredLogger
pub fn new(config: LogConfig) -> StructuredLogger
Create a new logger with configuration.
pub fn default_logger() -> StructuredLogger
pub fn default_logger() -> StructuredLogger
Create with default configuration.
pub fn development() -> StructuredLogger
pub fn development() -> StructuredLogger
Create a development logger.
pub fn production() -> StructuredLogger
pub fn production() -> StructuredLogger
Create a production logger.
pub fn set_enabled(&self, enabled: bool)
pub fn set_enabled(&self, enabled: bool)
Enable/disable logging.
pub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if logging is enabled.
pub fn set_config(&self, config: LogConfig)
pub fn set_config(&self, config: LogConfig)
Update configuration.
pub fn set_context(&self, context: TraceContext)
pub fn set_context(&self, context: TraceContext)
Set trace context.
pub fn context(&self) -> TraceContext
pub fn context(&self) -> TraceContext
Get current trace context.
pub fn start_trace(&self) -> TraceContext
pub fn start_trace(&self) -> TraceContext
Start a new trace.
pub fn stats(&self) -> LoggerStats
pub fn stats(&self) -> LoggerStats
Get statistics.
Trait Implementations§
§impl Default for StructuredLogger
impl Default for StructuredLogger
§fn default() -> StructuredLogger
fn default() -> StructuredLogger
Returns the “default value” for a type. Read more
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§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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
§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
§fn deserialize(
&self,
deserializer: &mut D,
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>
Deserializes using the given deserializer
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Gets the layout of the type.