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
impl PostfixLogEvent
Sourcepub 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
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
创建新的日志事件
Sourcepub fn event_type(&self) -> &'static str
pub fn event_type(&self) -> &'static str
获取事件类型描述
Sourcepub fn is_error_level(&self) -> bool
pub fn is_error_level(&self) -> bool
检查是否为错误级别的日志
Sourcepub fn is_warning_level(&self) -> bool
pub fn is_warning_level(&self) -> bool
检查是否为警告级别的日志
Sourcepub fn is_debug_level(&self) -> bool
pub fn is_debug_level(&self) -> bool
检查是否为调试级别的日志
Sourcepub fn severity_level(&self) -> u8
pub fn severity_level(&self) -> u8
获取日志等级的严重程度数值
Trait Implementations§
Source§impl Clone for PostfixLogEvent
impl Clone for PostfixLogEvent
Source§fn clone(&self) -> PostfixLogEvent
fn clone(&self) -> PostfixLogEvent
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 PostfixLogEvent
impl Debug for PostfixLogEvent
Source§impl<'de> Deserialize<'de> for PostfixLogEvent
impl<'de> Deserialize<'de> for PostfixLogEvent
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 PostfixLogEvent
impl RefUnwindSafe for PostfixLogEvent
impl Send for PostfixLogEvent
impl Sync for PostfixLogEvent
impl Unpin for PostfixLogEvent
impl UnwindSafe for PostfixLogEvent
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> 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