Improve ease of debugging an incorrect parser implementation by adding
context to the Err values from deku parsers by adding logging from the
log crate.
This is feature-gated under the new "logging" feature.
From the following sample program, you can easily see the improved error
message and debugging since we known the field that was incorrect
parsed. Much easier than gdb.
> RUST_LOG=trace cargo r
Finished dev [unoptimized + debuginfo] target(s) in 0.27s
Running `target/debug/deku-testing`
[2022-07-04T16:11:54Z TRACE deku_testing] Reading: TestStruct::a from [00000001, 00000010, 00000011]
[2022-07-04T16:11:54Z TRACE deku_testing] Reading: TestStruct::b from [00000011]
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Incomplete(NeedSize { bits: 16 })', src/main.rs:11:54
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
This could be expanded in the future to enums and/or other internal deku
structs.
Even cooler would be something like this:
|-----------------|
[2022-07-04T16:08:16Z TRACE deku_testing] Reading: TestStruct::a from [00000001, 00000010, 00000011]
From the following sample program, you can easily see the improved error message and debugging since we known the field that was incorrect parsed. Much easier than gdb.
This could be expanded in the future to enums and/or other internal deku structs.
Even cooler would be something like this:
See #168