Skip to content

Commit df94299

Browse files
author
Andrew Guldman
committed
Updated documentation about using debug in a browser
1 parent 2c38441 commit df94299

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

Readme.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,19 @@ Then, run the program to be debugged as ususal.
8383

8484
## Browser support
8585

86-
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()`.
86+
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:
87+
88+
```js
89+
window.myDebug = require("debug");
90+
```
91+
92+
("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:
93+
94+
```js
95+
myDebug.enable("worker:*")
96+
```
97+
98+
Refresh the page. Debug output will continue to be sent to the console until it is disabled by typing `myDebug.disable()` in the console.
8799

88100
```js
89101
a = debug('worker:a');

0 commit comments

Comments
 (0)