Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

RuntimeLogger fix #7927

Closed
pepyakin opened this issue Jan 18, 2021 · 0 comments · Fixed by #8128
Closed

RuntimeLogger fix #7927

pepyakin opened this issue Jan 18, 2021 · 0 comments · Fixed by #8128

Comments

@pepyakin
Copy link
Contributor

Right now in order to log something from the runtime using the log crate, you will have to initialize the RuntimeLogger first.

That leads to odd looking code such as this. This is done so that we don't format and send over to the host if the logging is not enabled. As soon as the logger is enabled it will send everything over to the host.

Now, that's a bit annoying because:

  • it's not a fundamental limitation. If one wants to print something badly, they can use the relevant API directly.
  • Even though the formatting code is compiled in and sitting there anyway (or at least it looks by the code, I haven't checked it in the final binary), in order to look at the output you'd need to recompile the wasm runtime.

For some cases it would be easier to just look at the output of the native runtime, for others there is no easy way.

Solution here, is to enable logging implicitly for every runtime call, detect the highest log level we need to print and then cache it in thread local so that we only do that once.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant