Skip to main content

Sqllog

Struct Sqllog 

Source
pub struct Sqllog<'a> {
    pub ts: Cow<'a, str>,
    pub meta_raw: Cow<'a, str>,
    pub content_raw: Cow<'a, [u8]>,
    pub tag: Option<Cow<'a, str>>,
    /* private fields */
}
Expand description

SQL 日志记录

表示一条完整的 SQL 日志记录,包含时间戳、元数据、SQL 语句体和可选的性能指标。

Fields§

§ts: Cow<'a, str>

时间戳,格式为 “YYYY-MM-DD HH:MM:SS.mmm”

§meta_raw: Cow<'a, str>

原始元数据字节(延迟解析)

§content_raw: Cow<'a, [u8]>

原始内容(包含 Body 和 Indicators),延迟分割和解析

§tag: Option<Cow<'a, str>>

提取出的方括号标签(例如 [SEL]、[ORA]),若无则为 None

Implementations§

Source§

impl<'a> Sqllog<'a>

Source

pub fn body(&self) -> Cow<'a, str>

获取 SQL 语句体(延迟分割)

Source

pub fn body_len(&self) -> usize

获取 SQL 语句体的长度(不做 UTF-8 校验,不分配)

Source

pub fn body_bytes(&self) -> &[u8]

获取 SQL 语句体的原始字节切片(不分配)

Source

pub fn indicators_raw(&self) -> Option<Cow<'a, str>>

获取原始性能指标字符串(延迟分割)

Source

pub fn parse_indicators(&self) -> Option<PerformanceMetrics<'static>>

解析性能指标(sql 字段为空字符串)

Source

pub fn parse_performance_metrics(&self) -> PerformanceMetrics<'a>

解析性能指标和 SQL 语句

返回包含 EXECTIME、ROWCOUNT、EXEC_ID 和 SQL 语句的 PerformanceMetrics

当 tag 为 "ORA" 时,SQL 语句开头可能带有 ": ",本方法会自动去除。

§实现说明

仅调用一次 find_indicators_split(),body 解码与 indicators 解析均在同一 次遍历中完成,Cow::Borrowed 路径全程零分配。

Source

pub fn parse_meta(&self) -> MetaParts<'a>

解析元数据

Trait Implementations§

Source§

impl<'a> Clone for Sqllog<'a>

Source§

fn clone(&self) -> Sqllog<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Sqllog<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Default for Sqllog<'a>

Source§

fn default() -> Sqllog<'a>

Returns the “default value” for a type. Read more
Source§

impl<'a> PartialEq for Sqllog<'a>

Source§

fn eq(&self, other: &Sqllog<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> StructuralPartialEq for Sqllog<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Sqllog<'a>

§

impl<'a> RefUnwindSafe for Sqllog<'a>

§

impl<'a> Send for Sqllog<'a>

§

impl<'a> Sync for Sqllog<'a>

§

impl<'a> Unpin for Sqllog<'a>

§

impl<'a> UnsafeUnpin for Sqllog<'a>

§

impl<'a> UnwindSafe for Sqllog<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.