feat: add uuid to logs

This commit is contained in:
itsscb 2025-07-24 11:53:53 +02:00
parent 1b945d09b1
commit 7a8d6e0e74
2 changed files with 8 additions and 0 deletions

View File

@ -7,3 +7,4 @@ edition = "2024"
chrono = { version = "0.4.41", features = ["serde"] } chrono = { version = "0.4.41", features = ["serde"] }
serde = { version = "1.0.219", features = ["derive"] } serde = { version = "1.0.219", features = ["derive"] }
serde_json = "1.0.141" serde_json = "1.0.141"
uuid = { version = "1.17.0", features = ["serde", "v4"] }

View File

@ -1,8 +1,10 @@
use chrono::{DateTime, Local}; use chrono::{DateTime, Local};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use uuid::Uuid;
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq, PartialOrd, Ord)] #[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq, PartialOrd, Ord)]
pub struct Item { pub struct Item {
id: Uuid,
content: String, content: String,
created: DateTime<Local>, created: DateTime<Local>,
modified: DateTime<Local>, modified: DateTime<Local>,
@ -17,12 +19,17 @@ impl Item {
self.content = content; self.content = content;
self.modified = Local::now(); self.modified = Local::now();
} }
pub fn id(&self) -> String {
self.id.to_string()
}
} }
impl Default for Item { impl Default for Item {
fn default() -> Self { fn default() -> Self {
let now = Local::now(); let now = Local::now();
Self { Self {
id: Uuid::new_v4(),
content: String::new(), content: String::new(),
created: now, created: now,
modified: now, modified: now,