Does 'debug' cache the DEBUG environment variable somewhere? Getting no output after changing namespace and DEBUG env var.
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- electron, javascript, typescript
- Ambito
- tooling
Direzione di ricerca
Start by reproducing the namespace change from foo to bar in the debug initialization, checking how process.env.DEBUG is read and how log.enabled differs. Run the Electron Forge command with cross-env DEBUG=bar and compare output for both namespaces; done means the observed namespace behavior is explained and the issue is either resolved or clearly documented.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
I am using 'debug' with TypeScript in an Electron project like so:
import debug from 'debug';
const log = debug('foo');
export default async function myFunction(name: string) {
log('calling myFunction');
...
log('successfully returning myFunction');
return someVariable;
}
in my shell (zsh) I set the DEBUG env var like so export DEBUG=foo and then started running my application. Everything worked fine. Eventually, I changed the namespace from foo to bar and now no matter what I do, I cannot get any output. I tried resetting DEBUG, I restarted my shell and set the environment variable again with export DEBUG=bar, I tried using the [cross-env]{https://www.npmjs.com/package/cross-env} to set it like so:
"scripts": {
"start": "tsc && cross-env DEBUG=bar NODE_ENV=development electron-forge start",
...
}
but nothing ever shows up.
I tried
import debug from 'debug';
const log = debug('bar');
console.log("DEBUG", process.env.DEBUG);
export default async function myFunction(name: string) {
log('calling myFunction');
...
log('successfully returning myFunction');
return someVariable;
}
and the console.log output is indeed: DEBUG bar.
The only way I can get it to work now is by doing:
import debug from 'debug';
const log = debug('bar');
log.enabled = true;
The moment I change const log = debug('bar'); back to const log = debug('foo'); , I get output messages for the foo namespace no matter what's in the DEBUG env var.
Any idea what might be happening here?
- Lingua principale
- JavaScript
- Stelle
- 11.5k
- Fork
- 992
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di debug-js/debug
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
-
Debug as JSON Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 28/100
Tutte le issue di debug-js/debug
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
HarperFast/skills#96 ·
-
[Block] Latest Posts [Type] Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
-
Daemon passes --experimental-wasm-jspi unconditionally on Node >= 24; Node 26 rejects the flag Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Automattic/studio#4908 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
sugarlabs/musicblocks#8847 ·