Skip to content

Commit

Permalink
Merge pull request #171 from gnaryak/master
Browse files Browse the repository at this point in the history
Updated documentation about using debug in a browser
  • Loading branch information
TooTallNate committed Jan 25, 2015
2 parents 2c38441 + df94299 commit 9272ee0
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 9272ee0

Please sign in to comment.