Skip to content

Commit

Permalink
Updated documentation about using debug in a browser
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Guldman committed Jan 20, 2015
1 parent 2c38441 commit df94299
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,19 @@ Then, run the program to be debugged as ususal.

## Browser support

Debug works in the browser as well, currently persisted by `localStorage`. For example if you have `worker:a` and `worker:b` as shown below, and wish to debug both type `debug.enable('worker:*')` in the console and refresh the page, this will remain until you disable with `debug.disable()`.
Debug works in the browser as well, currently persisted by `localStorage`. Consider the situation shown below where you have `worker:a` and `worker:b`, and wish to debug both. Somewhere in the code on your page, include:

```js
window.myDebug = require("debug");
```

("debug" is a global object in the browser so we give this object a different name.) When your page is open in the browser, type the following in the console:

```js
myDebug.enable("worker:*")
```

Refresh the page. Debug output will continue to be sent to the console until it is disabled by typing `myDebug.disable()` in the console.

```js
a = debug('worker:a');
Expand Down

0 comments on commit df94299

Please sign in to comment.