Skip to content
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

For web assembly, implement logging as emscripten_err and emscripten_out #6913

Merged
merged 1 commit into from
Jun 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions libs/utils/src/Log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
# endif
#endif

#if defined(__EMSCRIPTEN__)
#include <emscripten/console.h>
#endif

namespace utils {
namespace io {

Expand Down Expand Up @@ -66,7 +70,23 @@ ostream& LogStream::flush() noexcept {
__android_log_write(ANDROID_LOG_VERBOSE, UTILS_LOG_TAG, buf.get());
break;
}
#else // ANDROID
#elif defined(__EMSCRIPTEN__)
switch (mPriority) {
case LOG_DEBUG:
case LOG_WARNING:
case LOG_INFO:
_emscripten_out(buf.get());
break;
case LOG_ERROR:
_emscripten_err(buf.get());
break;
case LOG_VERBOSE:
#ifndef NFIL_DEBUG
_emscripten_out(buf.get());
#endif
break;
}
#else // not ANDROID or EMSCRIPTEN
switch (mPriority) {
case LOG_DEBUG:
case LOG_WARNING:
Expand All @@ -82,7 +102,7 @@ ostream& LogStream::flush() noexcept {
#endif
break;
}
#endif // __ANDROID__
#endif // __ANDROID__ or __EMSCRIPTEN__
buf.reset();
return *this;
}
Expand Down