Add some internal logging
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
This commit is contained in:
@@ -3,6 +3,7 @@ use std::{collections::HashSet, sync::Arc};
|
||||
use serde_json::{Value, json};
|
||||
use tokio::sync::Semaphore;
|
||||
|
||||
use tracing::{info, warn, error};
|
||||
use crate::{
|
||||
clients::{Destination, SupervisorClient, MyceliumClient},
|
||||
models::{Job, JobStatus, Message, MessageStatus, ScriptType, TransportStatus},
|
||||
@@ -40,7 +41,7 @@ pub fn start_router(service: AppService, cfg: RouterConfig) -> Vec<tokio::task::
|
||||
match MyceliumClient::new(cfg_cloned.base_url.clone()) {
|
||||
Ok(c) => break Arc::new(c),
|
||||
Err(e) => {
|
||||
eprintln!("[router ctx={}] MyceliumClient init error: {}", ctx_id, e);
|
||||
error!(context_id=ctx_id, error=%e, "MyceliumClient init error");
|
||||
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
|
||||
}
|
||||
}
|
||||
@@ -72,10 +73,7 @@ pub fn start_router(service: AppService, cfg: RouterConfig) -> Vec<tokio::task::
|
||||
if let Err(e) =
|
||||
deliver_one(&service_task, &cfg_task, ctx_id, &key, mycelium).await
|
||||
{
|
||||
eprintln!(
|
||||
"[router ctx={}] delivery error for {}: {}",
|
||||
ctx_id, key, e
|
||||
);
|
||||
error!(context_id=ctx_id, key=%key, error=%e, "Delivery error");
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -85,7 +83,7 @@ pub fn start_router(service: AppService, cfg: RouterConfig) -> Vec<tokio::task::
|
||||
continue;
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("[router ctx={}] brpop error: {}", ctx_id, e);
|
||||
error!(context_id=ctx_id, error=%e, "BRPOP error");
|
||||
// small backoff to avoid busy-loop on persistent errors
|
||||
tokio::time::sleep(std::time::Duration::from_millis(200)).await;
|
||||
}
|
||||
@@ -454,12 +452,12 @@ pub fn start_router_auto(service: AppService, cfg: RouterConfig) -> tokio::task:
|
||||
};
|
||||
let _ = start_router(service.clone(), cfg_ctx);
|
||||
active.insert(ctx_id);
|
||||
eprintln!("[router] started loop for context {}", ctx_id);
|
||||
info!(context_id=ctx_id, "Started loop for context");
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("[router] list_context_ids error: {}", e);
|
||||
error!(error=%e, "list_context_ids error");
|
||||
}
|
||||
}
|
||||
tokio::time::sleep(std::time::Duration::from_secs(5)).await;
|
||||
|
Reference in New Issue
Block a user