LibAFL icon indicating copy to clipboard operation
LibAFL copied to clipboard

Use log fascade

Open maxammann opened this issue 4 years ago • 7 comments

I think LibAFL could benefit from a generic logger as there are quite some messages which are sent to stdout. env_logger allows to configure logging externally and uses macros for the actual calls. This is similar to println!.

I do not have experience with Rust, but enjoyed to work with env_logger. I suppose this is the default in the Rust community atm.

What do you think? Does it make sense to switch to this? Or do we plan to avoid all logging and have a slick tui like AFL++?

maxammann avatar May 25 '21 16:05 maxammann

Actually you can already do it because SimpleStats and MultiStats use a closure to print logs

andreafioraldi avatar May 25 '21 19:05 andreafioraldi

I think that a proper logging library would be very useful. If possible, it should prefix output with a date/time-stamp and a thread/process id...

s1341 avatar May 26 '21 04:05 s1341

I think if we can make sure libafl does not output to stdout/stderror itself, but everything goes through the Stats, then we do not need to depend on the crate log.

There are some calls to println! though: https://github.com/maxammann/LibAFL/blob/2f54e9dc01b5846ab3542d24721758a1f02239ff/libafl/src/events/llmp.rs#L742

I see two options:

  • move all println! output to Stats
  • Add log dependency and let log coexist with the Stats

What do you think?

maxammann avatar May 26 '21 09:05 maxammann

I'm refering to the log fascade log here: https://crates.io/crates/log

maxammann avatar May 26 '21 09:05 maxammann

I'm refering to the log fascade log here: https://crates.io/crates/log

Yes I like it is it no_std too

andreafioraldi avatar May 26 '21 09:05 andreafioraldi

For me, Stats are output for the user during fuzzing, logs should be mostly for debugging and development. Makes sense to have both. :)

domenukk avatar May 26 '21 11:05 domenukk

I think a proper logging crate is definitely necessary.

Can we think of a way to date/time-stamp and process-id-stamp the dup2-ed output from launcher when --output is used? Is there some kind of 'magic stream' that will automatically do it for us?

s1341 avatar May 27 '21 05:05 s1341

Done with #1060

domenukk avatar Feb 14 '23 09:02 domenukk