// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

use std::mem;

use tracing_appender::non_blocking;
use tracing_subscriber::fmt;

#[expect(clippy::allow_attributes, reason = "detection depends on how/where it gets built")]
#[allow(dead_code, reason = "this is path-imported, so dead code detection has false positives")]
pub fn init_tracing() {
    let (non_blocking, guard) = non_blocking(std::io::stdout());

    fmt().with_writer(non_blocking).with_max_level(tracing::Level::DEBUG).init(); // sets stdout as a default output for logs generated by oxidizer

    #[expect(clippy::mem_forget, reason = "intentional, to keep it alive for lifetime of the example process")]
    // This is intentional, as the "guard" needs to be alive for the entire duration of the program.
    // Forgetting the guard here allows us to simplify this signature, and the caller is not required
    // to keep the guard alive.
    mem::forget(guard);
}
