初始化项目

This commit is contained in:
皮蛋13361098506
2025-01-06 16:01:02 +08:00
commit 1b77f62820
575 changed files with 69193 additions and 0 deletions

View File

@@ -0,0 +1 @@
package impl_console

View File

@@ -0,0 +1,84 @@
package impl_console
import (
"fmt"
"github.com/fatih/color"
)
type Logger struct {
}
// NewLogger
// @description: 构造控制台日志
// parameter:
// return:
// @*Logger:
func NewLogger() *Logger {
return &Logger{}
}
// InfoLog
// @description: 信息日志记录
// parameter:
// @format:日志格式
// @args:参数列表
// return:
func (cl *Logger) InfoLog(format string, args ...interface{}) {
c := color.New(color.FgGreen)
s := c.Sprint("Info:")
fmt.Println(s, fmt.Sprintf(format, args...))
}
// DebugLog
// @description: 调试日志记录
// parameter:
// @format:日志格式
// @args:参数列表
// return:
func (cl *Logger) DebugLog(format string, args ...interface{}) {
c := color.New(color.FgGreen)
s := c.Sprint("Debug:")
fmt.Println(s, fmt.Sprintf(format, args...))
}
// WarnLog
// @description: 警告日志记录
// parameter:
// @format:日志格式
// @args:参数列表
// return:
func (cl *Logger) WarnLog(format string, args ...interface{}) {
c := color.New(color.FgYellow)
_, _ = c.Println("Warn:", fmt.Sprintf(format, args...))
}
// ErrorLog
// @description: 错误日志记录
// parameter:
// @format:日志格式
// @args:参数列表
// return:
func (cl *Logger) ErrorLog(format string, args ...interface{}) {
c := color.New(color.FgRed)
_, _ = c.Println("Error:", fmt.Sprintf(format, args...))
}
// FatalLog
// @description: 致命错误日志记录
// parameter:
// @format:日志格式
// @args:参数列表
// return:
func (cl *Logger) FatalLog(format string, args ...interface{}) {
c := color.New(color.FgRed)
_, _ = c.Println("Fatal:", fmt.Sprintf(format, args...))
}
// CloseLog
// @description: 关闭日志
// parameter:
// @waitFinish:是否等待日志
// return:
func (cl *Logger) CloseLog(waitFinish bool) {
}

View File

@@ -0,0 +1,14 @@
package impl_console
import (
"testing"
)
func TestInfoLog(t *testing.T) {
log := NewLogger()
log.DebugLog("Debug test")
log.InfoLog("Info test")
log.WarnLog("Warn test")
log.ErrorLog("Error test")
log.FatalLog("Fatal test")
}