31 lines
740 B
Rust
31 lines
740 B
Rust
use std::collections::HashMap;
|
|
|
|
use orchid_api_derive::{Coding, Hierarchy};
|
|
|
|
use crate::{ExtHostNotif, TStr};
|
|
|
|
/// Describes what to do with a log stream.
|
|
/// Log streams are unstructured utf8 text unless otherwise stated.
|
|
#[derive(Clone, Debug, Coding, PartialEq, Eq, Hash)]
|
|
pub enum LogStrategy {
|
|
/// Context-dependent default stream, often stderr
|
|
Default,
|
|
/// A file on the local filesystem
|
|
File { path: String, append: bool },
|
|
/// Discard any log output
|
|
Discard,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Coding)]
|
|
pub struct Logger {
|
|
pub routing: HashMap<String, LogStrategy>,
|
|
pub default: Option<LogStrategy>,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Coding, Hierarchy)]
|
|
#[extends(ExtHostNotif)]
|
|
pub struct Log {
|
|
pub category: TStr,
|
|
pub message: String,
|
|
}
|