postfix_log_parser/events/
postfix_script.rs1use crate::events::base::BaseEvent;
7use serde::{Deserialize, Serialize};
8
9#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11pub enum PostfixScriptOperation {
12 Starting,
14 Running { pid: Option<u32> },
16 Refreshing,
18}
19
20#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
22pub enum PostfixScriptFatalError {
23 CannotExecutePostconf,
25 CannotExecuteCommand { command: String },
27 MissingPath { path: String },
29 Other { message: String },
31}
32
33#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
35pub enum PostfixScriptWarningType {
36 NotOwnedBy {
38 path: String,
39 expected_owner: String,
40 },
41 GroupWritable { path: String },
43 SymlinkLeaves { path: String },
45 Other { message: String },
47}
48
49#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
51pub enum PostfixScriptEvent {
52 SystemOperation {
54 base: BaseEvent,
55 operation: PostfixScriptOperation,
56 },
57 FatalError {
59 base: BaseEvent,
60 error: PostfixScriptFatalError,
61 },
62 Warning {
64 base: BaseEvent,
65 warning: PostfixScriptWarningType,
66 },
67}
68
69impl PostfixScriptEvent {
70 pub fn base(&self) -> &BaseEvent {
72 match self {
73 PostfixScriptEvent::SystemOperation { base, .. } => base,
74 PostfixScriptEvent::FatalError { base, .. } => base,
75 PostfixScriptEvent::Warning { base, .. } => base,
76 }
77 }
78
79 pub fn base_mut(&mut self) -> &mut BaseEvent {
81 match self {
82 PostfixScriptEvent::SystemOperation { base, .. } => base,
83 PostfixScriptEvent::FatalError { base, .. } => base,
84 PostfixScriptEvent::Warning { base, .. } => base,
85 }
86 }
87
88 pub fn event_type(&self) -> &'static str {
90 match self {
91 PostfixScriptEvent::SystemOperation { operation, .. } => match operation {
92 PostfixScriptOperation::Starting => "system_starting",
93 PostfixScriptOperation::Running { .. } => "system_running",
94 PostfixScriptOperation::Refreshing => "system_refreshing",
95 },
96 PostfixScriptEvent::FatalError { .. } => "fatal_error",
97 PostfixScriptEvent::Warning { .. } => "warning",
98 }
99 }
100}