init_once

Function init_once 

Source
pub fn init_once(config: Config)
Expand description

Initializes the global logger with an android logger.

This can be called many times, but will only initialize logging once, and will not replace any other previously initialized logger.

It is ok to call this at the activity creation, and it will be repeatedly called on every lifecycle restart (i.e. screen rotation).

Examples found in repository?
examples/system_log_level_overrides.rs (lines 71-77)
70fn main() {
71    android_logger::init_once(
72        android_logger::Config::default()
73            .with_tag("log_test")
74            // If set, this is the highest level to log unless overriddeby by the system.
75            // Note the verbosity can be *increased* through system properties.
76            .with_max_level(log::LevelFilter::Info),
77    );
78    // The log crate applies its filtering before we even get to android_logger.
79    // Pass everything down so that Android's liblog can determine the log level instead.
80    log::set_max_level(log::LevelFilter::Trace);
81
82    log::trace!("trace");
83    log::debug!("debug");
84    log::info!("info");
85    log::warn!("warn");
86    log::error!("error");
87}