update once

This commit is contained in:
XOF
2026-01-06 02:25:24 +08:00
commit 7bf4f27be3
25 changed files with 4587 additions and 0 deletions

37
pkg/logger/logger.go Normal file
View File

@@ -0,0 +1,37 @@
package logger
import (
"log"
"os"
)
// Logger 定义日志接口
type Logger interface {
Printf(format string, v ...interface{})
Println(v ...interface{})
}
// DebugLogger 实现 Logger 接口,支持调试模式
type DebugLogger struct {
Debug bool
}
// New 创建新的日志实例
func New(debug bool) Logger {
if !debug {
log.SetOutput(os.Stdout)
}
return &DebugLogger{Debug: debug}
}
func (l *DebugLogger) Printf(format string, v ...interface{}) {
if l.Debug {
log.Printf(format, v...)
}
}
func (l *DebugLogger) Println(v ...interface{}) {
if l.Debug {
log.Println(v...)
}
}