use std::time::Duration;
use master_log_client::{
configure, error, flush, info, log_entry, mlog, mlogf, warn, LogEntry, MasterLogConfig,
Severity,
};
use serde_json::json;
fn main() {
configure(
MasterLogConfig::from_env()
.api_key("dev-key")
.endpoint("http://127.0.0.1:8000")
.min_request_interval(Duration::from_millis(20))
.batch_size(100),
);
mlog("Telescope array online");
mlogf!("Captured frame {} for {}", 42, "M31");
info("Flat-field calibration completed");
log_entry(
LogEntry::new("Dome slit wind threshold approaching")
.severity(Severity::Warn)
.tags(["dome", "weather"])
.metadata(json!({ "wind_knots": 28, "limit_knots": 32 })),
);
warn("Seeing degraded");
log_entry(
LogEntry::with_title("Camera cooling alert", "CCD cooling loop failed to settle")
.severity(Severity::Error)
.tags(["ccd", "camera"])
.metadata(json!({ "setpoint_celsius": -20, "actual_celsius": -16.8 })),
);
error("Mount tracking watchdog tripped");
let result = flush(Duration::from_secs(5));
if !result.ok {
eprintln!(
"Master Log flush failed: {}",
result.error.unwrap_or_default()
);
}
}