abstreet/abstutil/src/logger.rs
Vinzent Steinberg fd3b0e2a14
Fix compilation failures and most clippy warnings (#642)
* abstutil: Fix compilation failure

* map_gui: Fix compilation

* traffic_signal_data: Fix compilation failure

* map_model: Fix compilation failure

* abstutil: Fix doctests

* abstio: Fix most clippy warnings

* abstutil: Fix most clippy warnings

* collisions: Fix clippy warning

* convert_osm: Fix clippy warnings

* sim: Fix most clippy warnings

* geom: Fix clippy warnings

* kml: Fix clippy warnings

* map_model: Fix most clippy warnings

* fifteen_min: Fix clippy warnings

* game: Fix many clippy warnings

* Disable some noisy clippy warnings

* headless: Fix clippy warnings

* importer: Fix clippy warnings

* map_editor: Fix clippy warnings

* map_gui: Fix clippy warnings

* osm_viewer: Fix clippy warnings

* parking_mapper: Fix most clippy warnings

* popdat: Fix clippy warnings

* santa: Fix clippy warnings

* sumo: Fix clippy warnings

* traffic_seitan: Fix clippy warning

* updater: Fix clippy warnings

* widgetry: Fix clippy warnings

* tests: Fix some clippy warnings

* Fix compilation on stable Rust

* Simplify unwrapping

* Make use of `Entry` more readable

* Fix formatting

* Fix code that was broken in the refactoring

* Apply cargo +stable fmt

* Fix code that was broken in the refactoring, second try

* Remove `Default` impls that are equivalent to `new`

* Remove obsolete clippy wrapper

* Avoid turbofish

* Prefer `unwrap_or_else` over allowing `clippy::or_fun_call`

* Remove redundant `into_iter`

* Fix typo

* Prefer `&& false` over commenting code out

* Fix some clippy warnings

Co-authored-by: Dustin Carlino <dabreegster@gmail.com>
2021-05-14 08:32:56 -07:00

50 lines
1.2 KiB
Rust

/// ## On native: uses env_log
///
/// You can adjust the log level without recompiling with the RUST_LOG env variable.
///
/// ```skip
/// RUST_LOG=debug cargo run --bin game
/// ```
///
/// This can be done on a per lib basis:
///
/// ```skip
/// RUST_LOG=my_lib=debug cargo run --bin game
/// ```
///
/// Or a module-by-module basis:
///
/// ```skip
/// RUST_LOG=my_lib::module=debug cargo run --bin game
/// ```
///
/// You can mix and match:
///
/// ```skip
/// # error logging by default, except the foo:bar module at debug level
/// # and the entire baz crate at info level
/// RUST_LOG=error,foo::bar=debug,baz=info cargo run --bin game
/// ```
///
/// For some special cases, you might want to use regex matching by specifying a pattern with the
/// "/":
///
/// ```skip
/// # only log once every 10k
/// RUST_LOG="fast_paths=debug/contracted node [0-9]+0000 " mike import_la
/// ```
///
/// ## On web: uses console_log
pub fn setup() {
#[cfg(target_arch = "wasm32")]
{
console_log::init_with_level(log::Level::Info).unwrap();
}
#[cfg(not(target_arch = "wasm32"))]
{
use env_logger::{Builder, Env};
Builder::from_env(Env::default().default_filter_or("info")).init();
}
}