Ability to control other options programatically
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 38/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- javascript
- Ambito
- developer-experience
Direzione di ricerca
Start by reading the existing initialization and enable paths, including the handling of process.env and browser localStorage described in the issue. Done means a callable debug.init() can re-read the relevant environment configuration, including DEBUG_COLORS, after dotenv.config() or equivalent setup without requiring a reload.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
I use the package dotenv and the dotenv.config(); function to load my config from a .env file. I would like my default .env file to contain the config:
DEBUG=my-app:*,-my-app:verbose*
DEBUG_COLORS=1
So that developers, with the default .env file will have a good experience.
I have found that I can get debug to honor my DEBUG environment variable with this snippet of code in my config file:
dotenv.config();
const DEBUG: false | string = process.env.DEBUG && process.env.DEBUG !== 'false' ? process.env.DEBUG : false;
if (isString(DEBUG) && DEBUG !== 'false') {
console.error(colors.yellow(`🐞 enabling debug outout for: "${DEBUG}". You can edit, or disable this in the .env file`));
Debug.enable(DEBUG);
}
but as far as I can tell, there is no way to get debug to switch the DEBUG_COLORS config over–once the package initializes and reads it from process.env, that's it. Unfortunately this doesn't work in this case.
Request: add a debug.init() method that can be called to re-read all of the environment configs–this way, once I know my environment is setup correctly, I can call debug.init and trust things will work.
I have run into the same exact issue with the debug package in the browser, though I did not know about debug.enableat the time. This point is moot, just wanted to provide it to share some insights with how I'm using it.
I have some FE code that says:
if (environment.local && !localStorage.debug) {
localStorage.debug = '...';
console.warn(`debug initialized–reload your browser and enable verbose logging in the console to see the output`);
}
In the front end case, I need to ship a change that uses debug.enable, and override the log to use console.log, and that will let me improve the experience.
- 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 ·