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
use super::AsyncSpawable;
use scsys::prelude::{BoxResult, Locked, Logger};
pub trait AppSpec: Default + AsyncSpawable {
type Cnf;
type Ctx;
type State;
fn init() -> Self;
fn context(&self) -> Self::Ctx;
fn name(&self) -> String;
fn settings(&self) -> Self::Cnf;
fn setup(&mut self) -> BoxResult<&Self>;
fn slug(&self) -> String {
self.name().to_ascii_lowercase()
}
fn state(&self) -> &Locked<Self::State>;
}
pub trait ApplicationLoggerSpec: AppSpec {
fn with_tracing(&self, level: Option<&str>) -> BoxResult<&Self> {
let mut logger = Logger::new(level.unwrap_or("info").to_string());
logger.setup(None);
tracing_subscriber::fmt::init();
Ok(self)
}
}