feat(log): category-toggleable debug log infrastructure#1685
Merged
Conversation
ZTS_DEBUG env 또는 NAPI `BundleOptions.debug` 로 카테고리별 진단 로그 토글. 비활성 카테고리는 단일 u64 AND 분기 후 즉시 리턴 — hot path 영향 없음. B2 (#1674) 실측용 std.debug.print 이 f6b2e66 로 main 에 남아있던 문제를 해결하면서 영구 진단 인프라로 격상. 첫 사용처 `compiled_cache`. ### 구성 - `src/debug_log.zig` 신규: `Category` enum, `enabled_mask: u64` 전역 bitmask, `enabled` / `print` / `addFromCsv` / `addCategories` / `initFromEnv` / `resetForTest` API + 4 unit tests - `src/root.zig` — `pub const debug_log` re-export - `src/main.zig` — CLI 진입 시 `debug_log.initFromEnv(allocator)` - `packages/core/src/napi_entry.zig` — NAPI register 1회 init + `parseBuildOptions` 에 `debug: string[]` 파싱 - `src/bundler/bundler.zig` — `BundleOptions.debug: []const []const u8` 필드, `Bundler.init` / `initWithResolveCache` 에서 `addCategories` 호출 - `src/bundler/incremental.zig` — 기존 `std.debug.print` 제거, `debug_log.print(.compiled_cache, ...)` 로 교체 - `packages/wasm/src/wasm_entry.zig` — transpile-only 이므로 생략, 주석으로 향후 bundler 추가 시 initFromEnv 필요함을 명시 - `docs/DEBUG.md` 신규 — 사용법/카테고리/형식/확장 방향 - `CLAUDE.md` — 문서 링크 추가 ### 활성화 예 ```bash ZTS_DEBUG=compiled_cache bun run bungae:start ``` ```ts build({ entryPoints: [...], debug: ['compiled_cache'] }) ``` 둘 다 합집합. 알 수 없는 카테고리는 silent ignore. ### Supersedes #1684 (debug print noise hotfix) — 이 PR 이 동일 문제를 더 근본적으로 해결 (print 제거 + 대체 인프라). 머지 후 #1684 close. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2 tasks
Smoke Test Results (CI)Smoke Test Results
Size Comparison (ZTS vs esbuild)
Average ratio: 0.82x | Smaller: 132 | Similar(±10%): 1 | Larger: 3
|
Benchmark Results (CI)macos-latesttranspile — small (100 lines)
transpile — medium (1K lines)
transpile — large (5K lines)
bundle — small (10 modules)
bundle — medium (50 modules)
bundle — large (200 modules)
small (100 lines)
medium (1K lines)
large (5K lines)
xlarge (10K lines)
ubuntu-latesttranspile — small (100 lines)
transpile — medium (1K lines)
transpile — large (5K lines)
bundle — small (10 modules)
bundle — medium (50 modules)
bundle — large (200 modules)
small (100 lines)
medium (1K lines)
large (5K lines)
xlarge (10K lines)
windows-latesttranspile — small (100 lines)
transpile — medium (1K lines)
transpile — large (5K lines)
bundle — small (10 modules)
bundle — medium (50 modules)
bundle — large (200 modules)
small (100 lines)
medium (1K lines)
large (5K lines)
xlarge (10K lines)
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ZTS_DEBUG env 또는 NAPI `BundleOptions.debug` 로 카테고리별 진단 로그 토글하는 경량 인프라. 첫 사용처는 `compiled_cache` (RFC #1672 B2). 비활성 카테고리는 단일 `u64` AND 분기 후 즉시 리턴 → hot path 영향 없음.
배경: B2 실측용 `std.debug.print` 가 f6b2e66 로 main 에 그대로 남아 production 에서 noise. #1684 가 print 만 제거하는 hotfix였는데, 이 PR 이 더 근본적으로 print 제거 + 영구 진단 인프라로 격상.
활성화
둘 다 합집합. 알 수 없는 이름은 silent ignore.
출력 형식
예:
변경
신규
수정
Supersedes
#1684 (debug print noise hotfix) — 이 PR 이 동일 문제를 더 근본적으로 해결. 머지 후 #1684 close.
Test plan
후속