Struct PostfixLogEvent

Source
pub struct PostfixLogEvent {
    pub raw_log: String,
    pub timestamp: DateTime<Utc>,
    pub hostname: String,
    pub component: String,
    pub process_id: u32,
    pub log_level: PostfixLogLevel,
    pub event: ComponentEvent,
    pub queue_id: Option<String>,
}
Expand description

统一的Postfix日志事件结构

这是解析后的日志事件的完整表示,包含所有基础字段和具体的事件数据

Fields§

§raw_log: String

原始日志行(完整的原始日志字符串) 用途:审计、调试、追溯原始数据 示例:“Jun 05 15:40:52 m01 postfix/smtpd[89]: connect from localhost[127.0.0.1]”

§timestamp: DateTime<Utc>

日志时间戳(UTC时间) 从日志行提取的时间信息,自动转换为UTC格式 格式:ISO 8601标准时间格式

§hostname: String

主机名(产生日志的服务器主机名) 从日志行中的第二个字段提取 示例:“m01”, “mail.example.com”

§component: String

Postfix组件名称(产生此日志的Postfix组件) 可能的值:smtpd, qmgr, smtp, cleanup, local, virtual等 对应Postfix架构中的不同功能模块

§process_id: u32

进程ID(产生日志的进程标识符) 从日志行中方括号内提取的数字 用于区分同一组件的不同进程实例

§log_level: PostfixLogLevel

日志等级(日志的重要性和严重程度) 基于Postfix源码中的msg_*函数分类 影响日志的过滤和告警策略

§event: ComponentEvent

具体的业务事件数据(解析后的结构化事件信息) 根据不同组件类型包含不同的事件结构 这是日志解析的核心价值所在

§queue_id: Option<String>

队列ID(邮件在Postfix队列系统中的唯一标识符) 用于跟踪单个邮件在系统中的完整生命周期 格式:通常为十六进制字符串,如“5BC302B027ED“

Implementations§

Source§

impl PostfixLogEvent

Source

pub fn new( raw_log: String, timestamp: DateTime<Utc>, hostname: String, component: String, process_id: u32, log_level: PostfixLogLevel, event: ComponentEvent, queue_id: Option<String>, ) -> Self

创建新的日志事件

Source

pub fn event_type(&self) -> &'static str

获取事件类型描述

Source

pub fn is_error_level(&self) -> bool

检查是否为错误级别的日志

Source

pub fn is_warning_level(&self) -> bool

检查是否为警告级别的日志

Source

pub fn is_debug_level(&self) -> bool

检查是否为调试级别的日志

Source

pub fn severity_level(&self) -> u8

获取日志等级的严重程度数值

Trait Implementations§

Source§

impl Clone for PostfixLogEvent

Source§

fn clone(&self) -> PostfixLogEvent

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 Debug for PostfixLogEvent

Source§

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

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

impl<'de> Deserialize<'de> for PostfixLogEvent

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for PostfixLogEvent

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,