feat: add starting and itermediate logs
This commit is contained in:
parent
f3e84f63f9
commit
0c2e129bbd
1 changed files with 6 additions and 4 deletions
10
src/main.rs
10
src/main.rs
|
|
@ -8,6 +8,8 @@ use tracing::{error, info};
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<()> {
|
async fn main() -> Result<()> {
|
||||||
|
info!("Starting noisebell...");
|
||||||
|
|
||||||
tracing_subscriber::fmt::init();
|
tracing_subscriber::fmt::init();
|
||||||
|
|
||||||
const DEFAULT_GPIO_PIN: u8 = 17;
|
const DEFAULT_GPIO_PIN: u8 = 17;
|
||||||
|
|
@ -21,16 +23,16 @@ async fn main() -> Result<()> {
|
||||||
|
|
||||||
let callback = move |event: gpio::CircuitEvent| {
|
let callback = move |event: gpio::CircuitEvent| {
|
||||||
info!("Circuit state changed: {:?}", event);
|
info!("Circuit state changed: {:?}", event);
|
||||||
|
|
||||||
// Clone the webhook notifier for the async block
|
|
||||||
let notifier = webhook_notifier.clone();
|
let notifier = webhook_notifier.clone();
|
||||||
|
|
||||||
// Spawn a new task to send webhooks
|
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
notifier.notify_all("circuit_state_change", event).await;
|
notifier.notify_all("circuit_state_change", event).await;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
info!("starting gpio_monitor");
|
||||||
|
|
||||||
if let Err(e) = gpio_monitor.monitor(callback).await {
|
if let Err(e) = gpio_monitor.monitor(callback).await {
|
||||||
error!("GPIO monitoring error: {}", e);
|
error!("GPIO monitoring error: {}", e);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue