Skip to content

Commit

Permalink
wasm: log output to browser JavaScript console (#163)
Browse files Browse the repository at this point in the history
Logging from the `log` facade goes to the colorized in-game GUI console (opened with the backtick key), as well as standard output using `println!` on the native build. To make this work on the wasm build, web-sys is used to access the `console` object, to call `console.log`, `console.warn`, and so on corresponding to the log levels. Extends #92, fails later (see also #115) but now outputs the starting up message:

[main.rs:206][INFO] Starting steven

* Add println! logging to console.log on wasm

* Initialize logger before config (called 'console variables' for some reason) to avoid having to disable it to reach the first logging statement

* Add web-sys crate for browser console access, wasm32-only

* Refactor logger to call println_level on both web/native

* Add multiple log levels, console.warn etc., matching console_log crate

https://github.com/iamcodemaker/console_log#details
  • Loading branch information
iceiix authored May 22, 2019
1 parent fd028d4 commit fd7add3
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 26 deletions.
Loading

0 comments on commit fd7add3

Please sign in to comment.