Importing the same library in all files

I have multiple files in my project and in each one I need to import a log like this:
use log::{debug, error, info, trace, warn}; because I want to use log4rs. I have all this files linked to main with mod file_name and in this file I also initialize log4rs. Is there other way I can import it to all files because it will be a pain if I will need to change this import in every file ?

Try use crate::log::*;? Or #[prelude_import] use log::*; on nightly.

Try #[macro_use] extern crate log; in the root mod (i.e. src/, and you can use all the macros from log after that line (even in sub mod).


extern crate log;

fn main() {

mod m {
    fn f() {
        info!(""); debug!("");
1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.