use std::fmt::Display;
pub mod client;
pub mod helper;
#[cfg(feature = "http-server")]
pub mod server_http;
#[cfg(feature = "native-client")]
pub mod task_manager;
pub type ProgramHandle = u64;
#[derive(Debug, Clone)]
pub struct LogEntry {
pub log: String,
pub timestamp: u64,
pub log_type: LogType,
}
impl Display for LogEntry {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let time = chrono::NaiveDateTime::from_timestamp_micros((self.timestamp * 1000) as _)
.unwrap()
.format("%Y-%m-%d %H:%M:%S")
.to_string();
write!(f, "<{}> <{}> {}", time, self.log_type, self.log)
}
}
#[derive(Debug, Clone)]
pub enum LogType {
Stdout,
Stderr,
Plain,
}
impl Display for LogType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
LogType::Stdout => write!(f, "STDOUT"),
LogType::Stderr => write!(f, "STDERR"),
LogType::Plain => write!(f, "PLAIN"),
}
}
}
pub const DEFAULT_MAXIMUM_LOG_ENTRIES: usize = 1000;