Function init

Source
pub fn init<S: AsRef<str>>(
    url: S,
    max_log_level: LevelFilter,
) -> Result<(), SetLoggerError>
Expand description

Configure the log facade to log to loki.

This function initialize the logger with no defaults static labels. To use them, you may want to use init_with_labels.

ยงExample

Usage:

use log::LevelFilter;

loki_logger::init(
    "http://loki:3100/loki/api/v1/push",
    log::LevelFilter::Info,
).unwrap();

log::info!("Logged into Loki !");
Examples found in repository?
examples/main.rs (line 3)
2async fn main() {
3    loki_logger::init("http://loki:3100/loki/api/v1/push", log::LevelFilter::Info).unwrap();
4
5    log::info!("Logged into Loki !");
6
7    // This is here so that the log has time to be sent asynchonously
8    #[allow(clippy::empty_loop)]
9    loop {}
10}