fake-log 0.1.0

A fake logging implementation with the same interface as log crate but with no-op implementation for embedded scenarios
//! no_std example of fake-log
//!
//! This example demonstrates how to use fake-log in a no_std environment,
//! which is common in embedded systems.

#![no_std]
#![no_main]

// For this example to work in a normal environment, we'll use a simple panic handler
// In a real embedded project, you would use your own panic handler
use core::panic::PanicInfo;

use fake_log::{debug, error, info, warn};

// Simple panic handler for this example
#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
    loop {}
}

// Entry point for no_std binary
#[no_mangle]
pub extern "C" fn main() -> ! {
    // Initialize hardware (simulated)
    init_hardware();

    // Main application loop
    loop {
        // Sensor reading simulation
        let temperature = read_temperature();
        let humidity = read_humidity();

        // Log sensor data (these calls are completely optimized away)
        info!("Temperature: {}°C", temperature);
        info!("Humidity: {}%", humidity);

        // Check for critical conditions
        if temperature > 80 {
            error!("Critical temperature: {}°C", temperature);
        } else if temperature > 60 {
            warn!("High temperature warning: {}°C", temperature);
        }

        // Debug information
        debug!("Sensor reading cycle completed");

        // Sleep simulation (in real embedded, this would be a proper sleep)
        for _ in 0..1000000 {
            core::hint::spin_loop();
        }
    }
}

fn init_hardware() {
    info!("Initializing hardware...");
    debug!("Setting up GPIO pins");
    debug!("Configuring SPI bus");
    debug!("Enabling interrupts");
    info!("Hardware initialization complete");
}

fn read_temperature() -> i32 {
    // Simulate temperature reading
    debug!("Reading temperature sensor");
    25 // Always return 25°C for this example
}

fn read_humidity() -> i32 {
    // Simulate humidity reading
    debug!("Reading humidity sensor");
    60 // Always return 60% for this example
}