Open stephan57160 opened 2 years ago
I mean ...
I saw a couple of debug!()
in flapigen code itself.
How to use this ?
Is there any 'debug' log file ?
There are no something special. It is the same old log
crate as everywhere.
You need register your logging implementation (for example env_logger )
in start of main and force it to output.
For example in cpp_tests: https://github.com/Dushistov/flapigen-rs/blob/b6b10fe44c745730beb1ac7e7a2fa87826b96823/cpp_tests/build.rs#L6
So you need to run build with RUST_LOG=debug to see debug output, details you can find in env_logger documentation.
There are only one specific thing for build scripts, you get build script stdout/stderr in case of error,
so if all OK, then RUST_LOG=debug cargo build
prints nothing, even you have thounds of debug!
,
to see stdout/stderr you need RUST_LOG=debug cargo build -vv
OK. Thx. Found it.
For those who will read this, in my build.rs
:
fn main() {
env_logger::init();
debug!("Stephan's log sample");
debug!("Stephan's log sample"); // twice !
debug!("Another log exmple");
let profile = std::env::var("PROFILE").unwrap();
With a
cargo clean
export RUST_LOG=debug ; cargo build
nothing happens on stdout.
But one can find the logs in target/debug/build/MyLibrary-xxx/stderr
:
DEBUG:<unknown>: Stephan's log sample
DEBUG:<unknown>: Stephan's log sample
DEBUG:<unknown>: Another log exmple
...
Note
Do not forget to clean, else, build.rs
is not executed if previous build is successful.
nothing happens on stdout.
As I wrote before you need "-vv" to see stdout of build script.
Do not forget to clean,
this is overkill, you need just touch path/to/build.rs
I'm currently trying to play with flapigen internals, let's say, for some experiment.
I'm sure it's a rookie question, but how to use debug!() and mainly, how to see its output ? Is there anything we have to initialise ? I suppose there is something to add in my library's
build.rs
, right ?