Ability to control other options programatically
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 38/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- javascript
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- JavaScript
- 星标
- 11.5k
- 派生
- 992
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
debug-js/debug 的其他 Issue
-
难度 1/5 1 小时以内 新手友好度 82/100
-
难度 4/5 3-5 天 新手友好度 25/100
-
Debug as JSON 未关闭
难度 5/5 一周以上 新手友好度 25/100
-
难度 3/5 1-2 天 新手友好度 35/100
-
难度 3/5 1-2 天 新手友好度 28/100
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 88/100
HarperFast/skills#96 ·
-
[Block] Latest Posts [Type] Bug
难度 2/5 1-3 小时 新手友好度 76/100
-
难度 2/5 1-3 小时 新手友好度 78/100
Automattic/studio#4908 ·
-
难度 2/5 1-3 小时 新手友好度 74/100
-
难度 2/5 1-3 小时 新手友好度 86/100
sugarlabs/musicblocks#8847 ·