Override `log()` functions with global ones
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- javascript
- Lĩnh vực
- tooling
Hướng nghiên cứu
Start in src/common.js, reading setup(env) and the logging path around the existing self.log and createDebug.log selection. Compare the reported patch with the current behavior and verify that a user-defined global debug.log takes precedence over namespace-specific log functions while the default logger preserves existing behavior.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch debug@4.3.4 for the project I'm working on.
As stated in #873, docs says that if setting a global debug.log() function, it will override the ones later specified at namespaces. This patch checks that debug.log() is different from the default one, and if so, then it has been defined by the user and will use it unconditionally.
Here is the diff that solved my problem:
diff --git a/node_modules/debug/src/common.js b/node_modules/debug/src/common.js
index e3291b2..e90e700 100644
--- a/node_modules/debug/src/common.js
+++ b/node_modules/debug/src/common.js
@@ -5,6 +5,8 @@
*/
function setup(env) {
+ const globalLog = env.log;
+
createDebug.debug = createDebug;
createDebug.default = createDebug;
createDebug.coerce = coerce;
@@ -109,7 +111,9 @@ function setup(env) {
// Apply env-specific formatting (colors, etc.)
createDebug.formatArgs.call(self, args);
- const logFn = self.log || createDebug.log;
+ const logFn = globalLog !== createDebug.log
+ ? createDebug.log
+ : (self.log || createDebug.log);
logFn.apply(self, args);
}
This issue body was partially generated by patch-package.
- 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 ·