@@ -39,32 +39,63 @@ Plus, [see the docs](https://substrate-system.github.io/debug/) generated by typ
3939## config
4040
4141### namespace
42- If you pass in a variable of the form ` VITE_DEBUG=example ` , then this will log
43- any instances created with the ` example ` namespace:
42+ Works with ` vite ` or other systems. This will look at ` import.meta.env ` , or
43+ an arbitrary object you can pass in.
4444
4545``` js
4646import Debug from ' @substrate-system/debug'
47+
48+ // look at `import.meta.env.VITE_DEBUG`
4749const debug = Debug (' example' )
50+
51+ // or call with your own env object
52+ const debug = Debug (' example' , { DEBUG : ' example' })
4853```
4954
5055If you create an instance without passing in a ` namespace ` string, then this
51- will log iff the website is in ` DEV ` mode (if ` import.meta.env.DEV ` is true).
56+ will log iff anything other than ` false ` is passed as an argument.
57+
58+ ``` js
59+ import Debug from ' @substrate-system/debug'
60+
61+ // log b/c we are not calling with `false`
62+ const debug = Debug ()
63+
64+ debug (' hello' )
65+ ```
66+
67+ You can use any variable as debug status:
68+
69+ ``` js
70+ import Debug from ' @substrate-system/debug'
71+
72+ // in Vite
73+ const debug = Debug (!! (import .meta.env && import.meta.env.DEV))
74+
75+ // in an arbitrary server
76+ const debug = Debug (window .EXAMPLE_DEBUG_MODE )
77+ ` ` `
5278
5379Use an env variable of ` * ` to log everything.
5480
81+
82+ ### NODE_ENV + Vite
83+
5584Build the site with a ` NODE_ENV ` variable to set ` import .meta.env.DEV` :
5685
5786` ` ` sh
5887NODE_ENV = development vite build
5988` ` `
6089
61- This will work too. Any value of ` NODE_ENV ` , except ` production ` , wil equate to
90+ Any value of ` NODE_ENV ` , except ` production` , wil equate to
6291` import .meta.env.DEV` being true.
6392
6493` ` ` sh
6594NODE_ENV = staging vite build
6695` ` `
6796
97+ ----------------------------------------------------------------------
98+
6899## install
69100
70101` ` ` sh
@@ -74,8 +105,10 @@ npm i -D @substrate-system/debug
74105Use this with [vite](https://vitejs.dev/) in the [browser](#browser), or
75106in [node](#node-JS).
76107
108+
77109------------------------------------------------------------------
78110
111+
79112## Node JS
80113Run your script with an env variable, ` DEBUG ` .
81114
@@ -116,6 +149,9 @@ Start a `vite` server and log some things. This uses [the example directory](./e
116149npm start
117150` ` `
118151
152+
153+ ## test
154+
119155### node
120156Run tests:
121157
0 commit comments