Does 'debug' cache the DEBUG environment variable somewhere? Getting no output after changing namespace and DEBUG env var.
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- electron, javascript, typescript
- Lĩnh vực
- tooling
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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?
- Ngôn ngữ chính
- JavaScript
- Star
- 11.5k
- Fork
- 992
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của debug-js/debug
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
-
Debug as JSON Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
-
console.group and groupCollapsed Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 28/100
Tất cả issue của debug-js/debug
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
HarperFast/skills#96 ·
-
[Block] Latest Posts [Type] Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
Daemon passes --experimental-wasm-jspi unconditionally on Node >= 24; Node 26 rejects the flag Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Automattic/studio#4908 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
sugarlabs/musicblocks#8847 ·