Crates.io | mgba_log |
lib.rs | mgba_log |
version | 0.2.1 |
source | src |
created_at | 2023-06-06 07:42:13.670406 |
updated_at | 2023-06-14 01:07:42.619094 |
description | A logging implementation for mGBA. |
homepage | |
repository | https://github.com/Anders429/mgba_log |
max_upload_size | |
id | 883611 |
size | 38,224 |
A logging implementation for mGBA.
Provides a logging implementation for the log
crate for logging when compiling for the Game Boy Advance and running within the mGBA emulator.
mGBA supports logging at the following log levels using the associated logging macros. Every level provided by the log
crate is supported except for Trace
, as mGBA has no analog for the Trace
log level, and this crate provides a macro for logging directly to Fatal
.
Level | Macro | Notes |
---|---|---|
Debug | log::debug! |
|
Info | log::info! |
|
Warn | log::warn! |
|
Error | log::error! |
|
Fatal | mgba_log::fatal! |
Not a standard log level. Only usable when using this logging implementation. |
mgba_log
should be used in binaries only. Libraries should instead use the logging facade provided by the log
crate directly.
When logging in a binary, only one logger may be enabled. Therefore, mgba_log
cannot be used alongside any other logging implementations.
Add mgba_log
as a dependency in your Cargo.toml
:
[dependencies]
mgba_log = "0.2.1"
Then call init()
early in your binary. Any records logged before initialization will be silently dropped.
fn main() {
mgba_log::init().expect("unable to initialize mGBA logger");
log::info!("Hello, world!");
}
Note that you may want to handle the returned Error
message from init()
more robustly, unless you only want your project to be run in mGBA.
This logger uses memory mapped IO registers specific to the Game Boy Advance. It is therefore only safe to use this library when building to run on the Game Boy Advance or a Game Boy Advance emulator.
If this logger is attempted to be initialized when not running on mGBA, it will fail to initialize with an Error
identifying the failure.
This project is 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.