Function gelf_logger::init

source ·
pub fn init(cfg: Config) -> Result<(), Error>
Expand description

Initialize the logger using the given Config.

§Warning

The logging system may only be initialized once.

§Example

use gelf_logger::Config;
use log::info;

let cfg = Config::builder()
    .set_hostname("myhost.com".into())
    .set_port(12202)
    .build();

gelf_logger::init(cfg).unwrap();

info!("hello");

gelf_logger::flush().expect("Failed to send buffer, log records can be lost!");