feat: structured logging with --debug flag + net.Listen for server addr resolution - #6
Merged
Merged
Conversation
Introduce log/slog-based logger package with DEBUG/INFO/WARN/ERROR levels. Both CLI and server support --debug flag to enable diagnostic output. Add debug logging throughout slice, vad, and adaptive-vad packages to aid troubleshooting and visibility into internal processing.
LiusCraft
force-pushed
the
feat/port-listen-addr
branch
from
May 4, 2026 15:25
bf0c273 to
2ca1404
Compare
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.
Background
log包,缺乏分级日志(INFO/WARN/ERROR/DEBUG),调试 VAD 处理过程困难Changes
logger/包:基于log/slog封装,支持 DEBUG/INFO/WARN/ERROR 四级,通过Init(debug)控制级别--debugflag:开启后输出所有级别的日志(默认只输出 INFO 及以上)slice/包添加调试日志:Split 分段裁剪/跳过、WriteWAV 文件写入、Resample 重采样参数vad/包添加调试日志:Detector 创建配置、Process 分块处理、Flush 结果、Detect 音频状态、参数变更vad/adaptive.go添加调试日志:自适应检测器创建参数、baseline 映射、RMS 后过滤详情cmd/server: 使用net.Listen获取实际监听地址(随机端口场景)Behavior Impact
--debug时日志输出级别与原log.Printf一致2024/01/01 12:00:00 message变为time=2024-01-01T12:00:00.000+08:00 level=INFO msg=message key=value--debug开启后会输出大量 VAD 内部处理细节,适合开发调试Risks and Rollback
bf0c273Verification
go vet ./logger/ ./slice/ ./html/通过go test ./slice/ ./html/通过gofmt检查无格式问题libonnxruntime无法验证,Go 代码编译通过Notes
init()函数默认初始化 Info 级别 logger,避免测试中 nil pointerlog.Fatalf统一替换为logger.Fatal(),内部调用os.Exit(1)