aboutsummaryrefslogtreecommitdiff
path: root/common/src/internal.rs
blob: 5aedfc7a83d03c5c43c2ec0627ae42c02a0ddb69 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
    This file is part of jellything (https://codeberg.org/metamuffin/jellything)
    which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
    Copyright (C) 2026 metamuffin <metamuffin.org>
*/

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",
        })
    }
}