add startup debug log

This commit is contained in:
LastExceed 2024-02-15 13:38:58 +01:00
parent d5f92d31bd
commit 124bdab3a8
2 changed files with 10 additions and 0 deletions

View File

@ -8,6 +8,8 @@ use state::{Announcer, Listener, State};
use utils::parse_toml_file; use utils::parse_toml_file;
use crate::utils::logs::log_start;
mod state; mod state;
mod utils; mod utils;
@ -34,6 +36,7 @@ lazy_static! {
#[tokio::main] #[tokio::main]
async fn main() { async fn main() {
magenta_ln!("===== spacermake ====="); magenta_ln!("===== spacermake =====");
log_start().expect("startup log failed");
print_config(); print_config();
let (client, event_loop) = create_client().await; let (client, event_loop) = create_client().await;
magenta_ln!("start"); magenta_ln!("start");

View File

@ -45,6 +45,13 @@ pub fn machinelog(machine: &str, booking: &Booking) -> io::Result<()> {
}) })
} }
pub fn log_start() -> io::Result<()> {
File::options()
.append(true)
.open("/root/machinelog_debug.csv")?
.write_all(format!("\n\n===== startup {} =====\n\n", Local::now()).as_bytes())
}
pub fn log_debug(topic: &str, payload: &str, result: Result<(), &str>) -> io::Result<()> { pub fn log_debug(topic: &str, payload: &str, result: Result<(), &str>) -> io::Result<()> {
if let Err(error) = result { if let Err(error) = result {
red_ln!("error: {error}"); red_ln!("error: {error}");