Logger for [godot-rust] projects
godot-logger
is a logger implementation for [godot-rust] projects that prints
logs using [godot_print!
].
Start by adding [godot-logger
] and [log
] as dependencies to your project's
Cargo.toml
.
toml
[dependencies]
godot-logger = "0.3.0"
log = "0.4"
Then configure and initialize the logger in the init
method that is passed to
godot_init!
.
```rust use gdnative::prelude::*; use godot_logger::{Filter, GodotLogger}; use log::{Level, LevelFilter};
fn init(handle: InitHandle) { GodotLogger::builder() .defaultloglevel(Level::Warn) .addfilter(Filter::new("godotlogger", LevelFilter::Debug)) .init();
log::debug!("Initialized the logger");
}
godot_init!(init); ```
The following will be printed in the Output console inside Godot:
text
2021-09-25 19:29:25 DEBUG godot-logger Initialized the logger
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.