simple_usage/
simple_usage.rs1use std::time::Duration;
2
3use master_log_client::{
4 configure, error, flush, info, log_entry, mlog, mlogf, warn, LogEntry, MasterLogConfig,
5 Severity,
6};
7use serde_json::json;
8
9fn main() {
10 configure(
12 MasterLogConfig::from_env()
13 .api_key("dev-key")
14 .endpoint("http://127.0.0.1:8000")
15 .min_request_interval(Duration::from_millis(20))
16 .batch_size(100),
17 );
18
19 mlog("Telescope array online");
20 mlogf!("Captured frame {} for {}", 42, "M31");
21
22 info("Flat-field calibration completed");
23
24 log_entry(
25 LogEntry::new("Dome slit wind threshold approaching")
26 .severity(Severity::Warn)
27 .tags(["dome", "weather"])
28 .metadata(json!({ "wind_knots": 28, "limit_knots": 32 })),
29 );
30
31 warn("Seeing degraded");
32
33 log_entry(
34 LogEntry::with_title("Camera cooling alert", "CCD cooling loop failed to settle")
35 .severity(Severity::Error)
36 .tags(["ccd", "camera"])
37 .metadata(json!({ "setpoint_celsius": -20, "actual_celsius": -16.8 })),
38 );
39
40 error("Mount tracking watchdog tripped");
41
42 let result = flush(Duration::from_secs(5));
43 if !result.ok {
44 eprintln!(
45 "Master Log flush failed: {}",
46 result.error.unwrap_or_default()
47 );
48 }
49}