slint
slint copied to clipboard
Replace eprintln with use of the log facade
This allows rust applications to have more control over the output the run-time library generates.
Follow-up question #1:
Should all our Rust examples use env_logger by default perhaps?
For C++ the path forward would be basically a front-end API to allow setting a hook, like what Olivier proposed:
enum LogType {
SlintDebug, //< The output of `debug()`in slint
Info, //< (Not sure)
Warning, // Some non-fatal error happened
Error, // Something really bad hapenned
}
using LogHook = void (*) (LogType type, std::string_view message);
slint::set_log_hook([](type, message) {
switch (type) {
//...
}
} );
Should all our Rust examples use env_logger by default perhaps?
i'm thinking the slint should enable a logger by default that print to stderr or something like that if the "log" feature is not set. It is otherwise pretty terrible if out of the box, a simple hello world don't show the warning on what went wrong if something goes wrong.
We could have a mod log in i_slint_core, that re-export the macro from the log crate, or just implement macro that print to stderr depending on a feature flag. (or should it be in i_slint_common since it is also used there?)
We should also remove the debug_log macro in favor of this.