pub struct QueryLogEntry {
pub timestamp: DateTime<Utc>,
pub level: LogLevel,
pub operation: String,
pub table: String,
pub duration_ms: u64,
pub rows_affected: Option<u64>,
pub success: bool,
pub error: Option<String>,
pub context: DbContext,
pub sql: Option<String>,
}Expand description
Query log entry
Fields§
§timestamp: DateTime<Utc>Timestamp
level: LogLevelLog level
operation: StringQuery operation (SELECT, INSERT, UPDATE, DELETE)
table: StringTable name
duration_ms: u64Query duration in milliseconds
rows_affected: Option<u64>Number of rows affected
success: boolWhether the query succeeded
error: Option<String>Error message (if any)
context: DbContextDatabase context
sql: Option<String>SQL statement (sanitized)
Implementations§
Source§impl QueryLogEntry
impl QueryLogEntry
Sourcepub fn new(operation: String, table: String, duration_ms: u64) -> Self
pub fn new(operation: String, table: String, duration_ms: u64) -> Self
Create a new query log entry
Sourcepub fn with_level(self, level: LogLevel) -> Self
pub fn with_level(self, level: LogLevel) -> Self
Set the log level
Sourcepub fn with_rows_affected(self, rows: u64) -> Self
pub fn with_rows_affected(self, rows: u64) -> Self
Set rows affected
Sourcepub fn with_error(self, error: String) -> Self
pub fn with_error(self, error: String) -> Self
Mark as failed
Sourcepub fn with_context(self, context: DbContext) -> Self
pub fn with_context(self, context: DbContext) -> Self
Set context
Trait Implementations§
Source§impl Clone for QueryLogEntry
impl Clone for QueryLogEntry
Source§fn clone(&self) -> QueryLogEntry
fn clone(&self) -> QueryLogEntry
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for QueryLogEntry
impl Debug for QueryLogEntry
Source§impl<'de> Deserialize<'de> for QueryLogEntry
impl<'de> Deserialize<'de> for QueryLogEntry
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 QueryLogEntry
impl RefUnwindSafe for QueryLogEntry
impl Send for QueryLogEntry
impl Sync for QueryLogEntry
impl Unpin for QueryLogEntry
impl UnwindSafe for QueryLogEntry
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