Skip to main content

basic/
basic.rs

1// =============================================================================
2//        #######
3//     ###       ###     F: basic.rs
4//    ##   ## ##   ##    P: AppCore-Runtime
5//         ## ##
6//                       C: unknown by dnettoRaw
7//    ##   ## ##   ##    U: working-tree by dnettoRaw
8//      ###########      S: 1.0.2-rc
9// =============================================================================
10
11//! Emit one safe structured operational event.
12//!
13//! Applications normally receive the same builder from
14//! `appcore_sdk::App::logger`.
15
16use appcore_log::{LogOutputMode, LoggerConfig};
17
18fn main() -> Result<(), appcore_log::LogConfigError> {
19    // Safe V4 terminal logging is explicit and creates no global state.
20    let logger = LoggerConfig {
21        output: LogOutputMode::Terminal,
22        ..LoggerConfig::default()
23    }
24    .build()?;
25
26    // The builder defaults to V4 and can be kept for related events.
27    let log = logger.dispatcher().event(0, "application");
28
29    log.info("application started");
30    log.warn("connection is slower than expected");
31    log.error("document could not be saved");
32
33    Ok(())
34}