Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document logging in Rust #21

Open
dominicparga opened this issue Sep 4, 2019 · 0 comments
Open

Document logging in Rust #21

dominicparga opened this issue Sep 4, 2019 · 0 comments
Labels
documentation Some info, link, help, description

Comments

@dominicparga
Copy link
Owner

//------------------------------------------------------------------------------------------------//
// logging
// from https://rust-lang-nursery.github.io/rust-cookbook/development_tools/debugging/config_log.html#include-timestamp-in-log-messages
// and https://doc.servo.org/env_logger/struct.Builder.html#examples-2

#[macro_use]
extern crate log;

// use chrono::Local;
use env_logger::Builder;
// use std::io::Write;
// use log::LevelFilter;

pub struct Logging;
impl Logging {
    pub fn init() {
        // e.g. export RUST_LOG='warn,osmgraphing::osm::pbf=debug'
        // -> first is global default
        // -> comma-separated `path::to::module=level`
        // where `path::to::module` is rooted in the name of the crate it was compiled for.
        Builder::from_env("RUST_LOG")
            // .format(|buf, record| {
            //     writeln!(
            //         buf,
            //         "{} [{}] - {}",
            //         Local::now().format("%Y-%m-%dT%H:%M:%S"),
            //         record.level(),
            //         record.args()
            //     )
            // })
            // .filter(None, LevelFilter::Error)
            .init();

        debug!("Initializing Logger has finished.");
    }
}
@dominicparga dominicparga added the documentation Some info, link, help, description label Sep 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Some info, link, help, description
Projects
None yet
Development

No branches or pull requests

1 participant