pub struct LogEntry {
pub timestamp: DateTime<Utc>,
pub level: LogLevel,
pub message: String,
pub context: LogContext,
pub module: Option<String>,
pub file: Option<String>,
pub line: Option<u32>,
pub target: Option<String>,
pub fields: HashMap<String, Value>,
}Expand description
Structured log entry
Fields§
§timestamp: DateTime<Utc>§level: LogLevel§message: String§context: LogContext§module: Option<String>§file: Option<String>§line: Option<u32>§target: Option<String>§fields: HashMap<String, Value>Implementations§
Source§impl LogEntry
impl LogEntry
Sourcepub fn new(
level: LogLevel,
message: impl Into<String>,
context: LogContext,
) -> Self
pub fn new( level: LogLevel, message: impl Into<String>, context: LogContext, ) -> Self
Create a new log entry
Sourcepub fn with_metadata(
self,
module: Option<&str>,
file: Option<&str>,
line: Option<u32>,
target: Option<&str>,
) -> Self
pub fn with_metadata( self, module: Option<&str>, file: Option<&str>, line: Option<u32>, target: Option<&str>, ) -> Self
Add metadata to the log entry
Sourcepub fn with_field(self, key: impl Into<String>, value: Value) -> Self
pub fn with_field(self, key: impl Into<String>, value: Value) -> Self
Add a field to the log entry
Sourcepub fn to_json_pretty(&self) -> Result<String>
pub fn to_json_pretty(&self) -> Result<String>
Convert to pretty JSON string
Trait Implementations§
Source§impl<'de> Deserialize<'de> for LogEntry
impl<'de> Deserialize<'de> for LogEntry
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for LogEntry
impl RefUnwindSafe for LogEntry
impl Send for LogEntry
impl Sync for LogEntry
impl Unpin for LogEntry
impl UnwindSafe for LogEntry
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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