-
Notifications
You must be signed in to change notification settings - Fork 623
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use logger for runtime prints #3097
Use logger for runtime prints #3097
Conversation
50446e4
to
ca9ffbe
Compare
ca9ffbe
to
8eacc28
Compare
@eloparco thanks for the PR, I am not sure whether it is a good practice to replace os_printf to LOG_VERBOSE, there are some concerns: (1) LOG_VERBOSE only outputs logs when I think we had better collect more input from other developers and check what is the best choice. |
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.
Suggest to only change the dump of error/failure to LOG_ERROR, and leave others unchanged first?
@@ -376,7 +376,7 @@ runtime_exception_handler(EXCEPTION_POINTERS *exce_info) | |||
#endif | |||
} | |||
|
|||
os_printf("Unhandled exception thrown: exception code: 0x%lx, " | |||
LOG_ERROR("Unhandled exception thrown: exception code: 0x%lx, " |
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.
Like the output of error/exception in wasm loader/instantiation/interpreter, I think it is an important info for developer, had better not use bh_log which adds timestamp and thread id?
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.
Like the output of error/exception in wasm loader/instantiation/interpreter
Which one are you referring to?
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 meant printing the error/exception in the product-mini main.c:
https://github.com/bytecodealliance/wasm-micro-runtime/blob/main/product-mini/platforms/posix/main.c#L899
https://github.com/bytecodealliance/wasm-micro-runtime/blob/main/product-mini/platforms/posix/main.c#L970
They are printed with printf, I am not sure whether here we should also use printf to dump "Unhandled exception thrown: xxx" like them.
35887b9
to
5a19f05
Compare
5a19f05
to
7818444
Compare
Yes, makes sense, I reverted all the replacements for |
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.
LGTM
Change runtime internal error/debug prints from using `os_printf()` to using `LOG_ERROR()`/`LOG_DEBUG()`.
When reporting logs from the runtime, it's better to use
BH_LOG
(since it can be overridden withWAMR_BH_LOG
) instead ofos_printf
. In this way, we can distinguish runtime output from wasm execution output.From #3070:
Occurrences of
os_printf
have been replaced, apart from a few files (e.g. the platform-specific ones incore/shared/platforms/
).