Crates.io | godot-logger |
lib.rs | godot-logger |
version | 1.1.0 |
source | src |
created_at | 2021-09-25 18:37:19.160498 |
updated_at | 2022-12-16 20:39:21.777152 |
description | A logger for godot-rust projects that prints logs using the godot_print! macro |
homepage | |
repository | https://github.com/jdno/godot-logger |
max_upload_size | |
id | 456255 |
size | 41,771 |
A logger for godot-rust projects
godot-logger
is an easy-to-use logger for godot-rust projects. It prints
logs to Godot's output console and supports module-specific log levels.
Start by adding godot-logger
and log
as dependencies to your project's
Cargo.toml
.
[dependencies]
godot-logger = "1.1.0"
log = "0.4"
Then configure and initialize the logger in the init
method that is passed to
godot_init!
.
use gdnative::prelude::*;
use godot_logger::GodotLogger;
use log::{Level, LevelFilter};
fn init(handle: InitHandle) {
if let Err(error) = GodotLogger::builder()
.default_log_level(Level::Info)
.add_filter("godot_logger", LevelFilter::Debug)
.init()
{
godot_warn!("{}", error.to_string());
}
log::debug!("Initialized the logger");
}
godot_init!(init);
The following will be printed in the Output console inside Godot:
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.