Rust HTTP client for the nfo centralized logging service using reqwest.
nfo_log()— async log entry via HTTP POSTnfo_log_batch()— batch multiple entriesnfo_query()— query logs from the service- Configurable via
NFO_URLenvironment variable
Start the HTTP service first:
python examples/http-service/main.pycd examples/rust-client
# Add to Cargo.toml: reqwest, serde, serde_json, tokio
cargo run#[derive(Serialize)]
struct LogEntry<'a> {
cmd: &'a str,
args: Vec<&'a str>,
language: &'a str,
}
pub async fn nfo_log(cmd: &str, args: Vec<&str>) {
let client = Client::new();
let entry = LogEntry { cmd, args, language: "rust" };
let _ = client.post(&format!("{}/log", nfo_url()))
.json(&entry)
.send()
.await;
}