-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Fix logging from inside the WASM runtime #7355
Conversation
When using `RuntimeLogger` to log something from the runtime, we didn't set any logging level. So, we actually did not log anything from the runtime as logging is disabled by default. This pr fixes that by setting the logging level to `TRACE`. It also adds a test to ensure this does not break again ;)
frame/support/src/debug.rs
Outdated
@@ -185,6 +193,7 @@ impl log::Log for RuntimeLogger { | |||
} | |||
|
|||
fn log(&self, record: &log::Record) { | |||
debug(&"Hey2"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose this is not intended.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦🤦
// | ||
// If we don't set any level, logging is disabled | ||
// completly. | ||
log::set_max_level(log::LevelFilter::Trace); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIR it shouldn't matter. We already return true
in log::Log::enabled
which should be responsible for filtering like that? Are you sure it's actually filtered somewhere internally in log
crate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I checked that. Remove the line and the test fails ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://docs.rs/log/0.4.11/log/#implementing-a-logger
They also mention it here that you need to call it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://docs.rs/log/0.4.11/src/log/macros.rs.html#46
Here they call the max_level function that checks the value that is set with set_max_value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough!
// | ||
// If we don't set any level, logging is disabled | ||
// completly. | ||
log::set_max_level(log::LevelFilter::Trace); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough!
When using
RuntimeLogger
to log something from the runtime, we didn'tset any logging level. So, we actually did not log anything from the
runtime as logging is disabled by default. This pr fixes that by setting
the logging level to
TRACE
. It also adds a test to ensure this doesnot break again ;)