Does 'debug' cache the DEBUG environment variable somewhere? Getting no output after changing namespace and DEBUG env var.
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 35/100
- Type d'issue
- Bug
- Clarté
- À clarifier
- Activité
- À l'abandon
- Stack technique
- electron, javascript, typescript
- Domaine
- tooling
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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?
- Langage dominant
- JavaScript
- Étoiles
- 11.5k
- Forks
- 992
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de debug-js/debug
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 82/100
-
Difficulté 4/5 3-5 jours Accessibilité débutants 25/100
-
Debug as JSON Ouverte
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 25/100
-
console.group and groupCollapsed Ouverte
Difficulté 3/5 1-2 jours Accessibilité débutants 35/100
-
Difficulté 3/5 1-2 jours Accessibilité débutants 28/100
Toutes les issues de debug-js/debug
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
HarperFast/skills#96 ·
-
[Block] Latest Posts [Type] Bug
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
-
Daemon passes --experimental-wasm-jspi unconditionally on Node >= 24; Node 26 rejects the flag Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Automattic/studio#4908 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 86/100
sugarlabs/musicblocks#8847 ·