绑定日志与命令行关联

This commit is contained in:
zyj
2026-03-04 16:21:03 +08:00
parent 9a2eabcf43
commit 72ac24f7cd
2 changed files with 46 additions and 12 deletions

View File

@@ -8,18 +8,9 @@ import (
)
func main() {
// 初始化日志
logOpts := logging.Options{
Level: "info",
LogFile: "devpack.log",
Verbose: false,
Quiet: false,
NoColor: false,
}
_, err := logging.Init(logOpts)
if err != nil {
os.Exit(1)
}
// 日志由 rootCmd.PersistentPreRunE 根据 CLI 参数自动初始化
// 程序退出时关闭日志文件句柄
defer logging.G().Close()
if err := commands.Execute(); err != nil {
os.Exit(1)