Skip to content

Commit

Permalink
For web assembly, implement logging as emscripten_err and emscripten_…
Browse files Browse the repository at this point in the history
…out (#6913)
  • Loading branch information
bejado committed Jun 22, 2023
1 parent 1edad92 commit 9fa952d
Showing 1 changed file with 22 additions and 2 deletions.
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

0 comments on commit 9fa952d

Please sign in to comment.