1use std::fmt::Display;
7
8pub mod client;
10pub mod helper;
12#[cfg(feature = "http-server")]
14pub mod server_http;
15#[cfg(feature = "native-client")]
17pub mod task_manager;
18
19pub type ProgramHandle = u64;
21
22#[derive(Debug, Clone)]
24pub struct LogEntry {
25 pub log: String,
26 pub timestamp: u64,
27 pub log_type: LogType,
28}
29
30impl Display for LogEntry {
31 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
32 let time = chrono::NaiveDateTime::from_timestamp_micros((self.timestamp * 1000) as _)
33 .unwrap()
34 .format("%Y-%m-%d %H:%M:%S")
35 .to_string();
36 write!(f, "<{}> <{}> {}", time, self.log_type, self.log)
37 }
38}
39
40#[derive(Debug, Clone)]
42pub enum LogType {
43 Stdout,
44 Stderr,
45 Plain,
46}
47
48impl Display for LogType {
49 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
50 match self {
51 LogType::Stdout => write!(f, "STDOUT"),
52 LogType::Stderr => write!(f, "STDERR"),
53 LogType::Plain => write!(f, "PLAIN"),
54 }
55 }
56}
57
58pub const DEFAULT_MAXIMUM_LOG_ENTRIES: usize = 1000;