From 5caf1f1db721d6dee2ddb5d0613e8c9914ccf879 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Fri, 20 Feb 2026 01:23:38 +0100 Subject: admin log --- common/Cargo.toml | 2 ++ common/src/api.rs | 4 +++- common/src/internal.rs | 31 +++++++++++++++++++++++++++++++ common/src/routes.rs | 3 --- 4 files changed, 36 insertions(+), 4 deletions(-) (limited to 'common') diff --git a/common/Cargo.toml b/common/Cargo.toml index 4eae9f8..fabd3d2 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -6,3 +6,5 @@ edition = "2024" [dependencies] jellystream-types = { path = "../stream/types" } jellyobject = { path = "object", features = ["json"] } +serde_json = "1.0.149" +serde = { version = "1.0.228", features = ["derive"] } diff --git a/common/src/api.rs b/common/src/api.rs index 3c4e958..12d9243 100644 --- a/common/src/api.rs +++ b/common/src/api.rs @@ -26,11 +26,13 @@ fields! { VIEW_ADMIN_DASHBOARD: () = b"adda"; VIEW_ADMIN_IMPORT: Object = b"adim"; VIEW_ADMIN_INFO: Object = b"adin"; + VIEW_ADMIN_LOG: Object = b"adlo"; ADMIN_IMPORT_BUSY: () = b"busy"; ADMIN_IMPORT_ERROR: &str = b"erro"; // multi ADMIN_INFO_TITLE: &str = b"aiti"; ADMIN_INFO_TEXT: &str = b"aite"; + ADMIN_LOG_MESSAGE: &str = b"aite"; NKU_NODE: Object = b"node"; NKU_UDATA: Object = b"udat"; @@ -38,7 +40,7 @@ fields! { NODELIST_TITLE: &str = b"titl"; NODELIST_DISPLAYSTYLE: Tag = b"dsty"; - NODELIST_ITEM: Object = b"item"; + NODELIST_ITEM: Object = b"item"; // multi MESSAGE_KIND: &str = b"kind"; MESSAGE_TEXT: &str = b"text"; diff --git a/common/src/internal.rs b/common/src/internal.rs index 58a2dae..5aedfc7 100644 --- a/common/src/internal.rs +++ b/common/src/internal.rs @@ -4,9 +4,40 @@ Copyright (C) 2026 metamuffin */ +use std::fmt::Display; + use jellyobject::fields; +use serde::{Deserialize, Serialize}; fields! { IM_PATH: &str = b"Ipth"; IM_MTIME: u64 = b"Imtm"; } + +#[derive(Serialize, Deserialize, Clone)] +pub struct LogLine { + pub time: String, + pub module: Option<&'static str>, + pub level: LogLevel, + pub message: String, +} + +#[derive(Serialize, Deserialize, Clone, Copy, PartialEq)] +pub enum LogLevel { + Trace, + Debug, + Info, + Warn, + Error, +} +impl Display for LogLevel { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_str(match self { + LogLevel::Trace => "trace", + LogLevel::Debug => "debug", + LogLevel::Info => "info", + LogLevel::Warn => "warn", + LogLevel::Error => "error", + }) + } +} \ No newline at end of file diff --git a/common/src/routes.rs b/common/src/routes.rs index fcef144..82a6f45 100644 --- a/common/src/routes.rs +++ b/common/src/routes.rs @@ -73,9 +73,6 @@ pub fn u_admin_import_post(incremental: bool) -> String { pub fn u_admin_update_search() -> String { "/admin/update_search".to_string() } -pub fn u_account_register() -> String { - "/account/register".to_owned() -} pub fn u_account_login() -> String { "/account/login".to_owned() } -- cgit v1.3