feat(cli): add -v debug flags to trace file writes and env path creations during deployment

This commit is contained in:
2026-03-24 17:16:58 +08:00
parent b1c7b9f8f7
commit 35bf24f0f3
3 changed files with 31 additions and 7 deletions

View File

@@ -12,6 +12,7 @@ import (
)
var fileLogger *lumberjack.Logger
var debugEnabled bool
func InitLogger() error {
logDir := config.GetLogDir()
@@ -33,6 +34,10 @@ func InitLogger() error {
return nil
}
func EnableDebug() {
debugEnabled = true
}
func writeLog(level, plainPrefix, format string, v ...interface{}) {
msg := fmt.Sprintf(format, v...)
timestamp := time.Now().Format("2006/01/02 15:04:05")
@@ -63,11 +68,19 @@ func getPrefixColor(level string) func(a ...interface{}) string {
return color.New(color.FgRed).SprintFunc()
case "CRITICAL":
return color.New(color.FgHiRed).SprintFunc()
case "DEBUG":
return color.New(color.FgCyan).SprintFunc()
default:
return color.New(color.Reset).SprintFunc()
}
}
func Debug(format string, v ...interface{}) {
if debugEnabled {
writeLog("DEBUG", "[DEBUG]", format, v...)
}
}
func Info(format string, v ...interface{}) {
writeLog("INFO", "[INFO]", format, v...)
}