log_unstructured/
log_unstructured.rs

1use std::{env, time::Duration};
2
3use log::info;
4use logscale_log::{
5    logscale_unstructured_logger::LogScaleUnstructuredLogger, options::LoggerOptions,
6};
7
8#[tokio::main]
9async fn main() {
10    let args: Vec<String> = env::args().collect();
11
12    let ingest_token = args
13        .get(1)
14        .expect("Missing '--ingest-token' parameter.")
15        .replace("--ingest-token=", "");
16
17    LogScaleUnstructuredLogger::init(
18        String::from("https://cloud.community.humio.com"),
19        ingest_token,
20        LoggerOptions::default(),
21    )
22    .unwrap();
23
24    log::set_max_level(log::LevelFilter::Trace);
25
26    // Loop to let the background sync task have time to do its thing.
27    // Assumes that the provided ingest token has been set up with an "accesslog" parser to be able to parse the log line below.
28    loop {
29        info!("192.168.1.21 - user1 [26/Sep/2023:14:48:26 +0000] \"POST /humio/api/v1/ingest/elastic-bulk HTTP/1.1\" 200 0 \"-\" \"useragent\" 0.015 664 0.015");
30
31        std::thread::sleep(Duration::from_secs(1));
32    }
33}