You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We should expose a hook in C++ to intercept the panics and logs.
One step will be to use the log crate in Rust for our own logs: #3099
But regardless, we should allow a hook in C++
Proposed API:
namespaceslint {
structLogMessage {
enumclassLevel {
/// A panic occurred. This is a bug in Slint. The process is going to be terminated after this.
Panic,
/// Some recoverable error happened, such as an image could not be loaded
Error,
//Warn, // (we don't currently have such message, do we?)/// Some information message (eg, the fps from SLINT_DEBUG_PERFORMANCE)
Info,
/// Output of `debug()` function from slint
Debug,
};
Level level;
string_view message;
string_view file;
int line;
// prevent the user to construct as aggregate that would prevent us to add fields in the futureprivate:void*reserved;
};
/// Set a hook that is called when Slint would usually display a log message./// If the hook return true, this would mean the default message should not be called.voidset_message_hook(bool (*) (LogMessage message) );
}
For the panic, the use of string_view message means that one must render the panic in a String, which allocates. And allocating in a panic handler might not be ideal. Alternative is to call the hook for each part of the message, but that's a terrible API imho while allocating in the panic handler should still be rather safe.
The text was updated successfully, but these errors were encountered:
We should expose a hook in C++ to intercept the panics and logs.
One step will be to use the
log
crate in Rust for our own logs: #3099But regardless, we should allow a hook in C++
Proposed API:
For the panic, the use of
string_view message
means that one must render the panic in a String, which allocates. And allocating in a panic handler might not be ideal. Alternative is to call the hook for each part of the message, but that's a terrible API imho while allocating in the panic handler should still be rather safe.The text was updated successfully, but these errors were encountered: