Skip to content

Commit

Permalink
docs(book): updated debugging docs
Browse files Browse the repository at this point in the history
  • Loading branch information
arctic-hen7 committed Jan 16, 2022
1 parent b7e8389 commit 7adf684
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion docs/next/en-US/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@

If you're used to Rust, you might be expecting to be able to call `println!` or `dbg!` to easily print a value to the browser console while working on an app, however this is unfortunately not yet the case (this is an issue in the lower-level libraries that Perseus depends on).

However, Perseus exports a macro called `web_log!` that can be used to print to the console. It accepts syntax identical to `format!`, `println!`, and the like and behaves in the same way, but it will print to the browser console instead of the terminal.
However, Perseus exports a macro called `web_log!` that can be used to print to the console. It accepts syntax identical to `format!`, `println!`, and the like and behaves in the same way, but it will print to the browser console instead of the terminal. Because Perseus builds your templates on the server as well as in the browser though, some of the calls to this macro may run both on a 'normal' architecture and in Wasm. `web_log!` is designed for this, and will print to `stdout` (as `println!` does) if it's used on the server-side (though you'll need to run something like `perseus snoop build` to see the output).

## Debugging the build process

If you have a problem in your build process, you'll probably notice quite quickly that you can't see any `dbg!`, `println!`, or `web_log!` calls in your terminal when you run `perseus serve` (or `export`, `build`, etc.). This is because the CLI hides the output of the commands that it runs behind the scenes (if you've ever had the CLI spout an error at you and show you everything it's done behind the scenes, you'll probably understand why!). As useful as this is for simple usability, it can be extremely annoying for loggin, so the CLI provides a separate command `perseus snoop <process>`, which allows you to run one of the commands that the CLI does, directly. Usually, this will be `perseus snoop build`, though you can also use `perseus snoop wasm-build` if you're having an issue in your Wasm building (usually caused by a crate that can't work in the browser), or `perseus snoop serve` if you're getting errors on the server (which shouldn't happen unless you've modified it). To learn more, see [this page](:snooping).

0 comments on commit 7adf684

Please sign in to comment.