Skip to main content

melodium_common/executive/log/
mod.rs

1use chrono::{DateTime, Utc};
2use core::fmt::{Debug, Display};
3use serde::{Deserialize, Serialize};
4use uuid::Uuid;
5
6#[derive(Debug, Serialize, Deserialize, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
7pub enum Level {
8    Error,
9    Warning,
10    Info,
11    Debug,
12    Trace,
13}
14
15impl Display for Level {
16    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
17        match self {
18            Level::Error => write!(f, "error"),
19            Level::Warning => write!(f, "warning"),
20            Level::Info => write!(f, "info"),
21            Level::Debug => write!(f, "debug"),
22            Level::Trace => write!(f, "trace"),
23        }
24    }
25}
26
27#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
28pub struct Log {
29    pub timestamp: DateTime<Utc>,
30    pub level: Level,
31    pub label: String,
32    pub message: String,
33    pub track_id: Option<usize>,
34    pub run_id: Option<Uuid>,
35    pub group_id: Option<Uuid>,
36}