1 Star 3 Fork 0

丁丁 / dingapi

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
dinglog.go 958 Bytes
一键复制 编辑 原始数据 按行查看 历史
丁丁 提交于 2021-10-24 13:36 . 修复了时间格式化错误的问题
package dinglog
import (
"path"
"runtime"
"strconv"
"time"
"github.com/gookit/color"
)
func maketime() string {
timeres := time.Now()
return timeres.Format("2006-01-02") + " " + strconv.Itoa(timeres.Hour()) + ":" + strconv.Itoa(timeres.Minute())
}
func Debug(text string) {
_, file, line, _ := runtime.Caller(1)
color.Yellowp("(/", path.Base(file), " ", line, ") ")
color.Bold.Print(maketime(), " ")
color.Print("[")
color.Bluep(color.Bold.Text("debug"))
color.Print("] ")
color.Bold.Println(text)
}
func Info(text string) {
color.Bold.Print(maketime(), " ")
color.Print("[")
color.Greenp(color.Bold.Text("info"))
color.Print("] ")
color.Bold.Println(text)
}
func Error(text string) {
_, file, line, _ := runtime.Caller(1)
color.Yellowp("(/", path.Base(file), " ", line, ") ")
color.Bold.Print(maketime(), " ")
color.Print("[")
color.Redp(color.Bold.Text("erorr"))
color.Print("] ")
color.Bold.Println(color.Red.Text(text))
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/dinglz/dingapi.git
git@gitee.com:dinglz/dingapi.git
dinglz
dingapi
dingapi
50caa38d6ef1

搜索帮助

344bd9b3 5694891 D2dac590 5694891