1 Star 1 Fork 1

menuiis/logx

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
main.go 894 Bytes
一键复制 编辑 原始数据 按行查看 历史
menuis 提交于 2023-09-16 12:59 . init
package main
import (
"gitee.com/menciis/logx"
)
func main() {
// Let's add a custom level,
//
// It should be starting from level index 6,
// because we have 6 built'n levels (0 is the start index):
// disable,
// fatal,
// error,
// warn,
// info
// debug
// First we create our level to a golog.Level
// in order to be used in the Log functions.
var SuccessLevel logx.Level = 6
// Register our level, just three fields.
logx.Levels[SuccessLevel] = &logx.LevelMetadata{
Name: "success",
Title: "[SUCC]",
ColorCode: 32, // Green
}
// create a new golog logger
myLogger := logx.New()
// set its level to the higher in order to see it
// ("success" is the name we gave to our level)
myLogger.SetLevel("success")
// and finally print a log message with our custom level
myLogger.Logf(SuccessLevel, "This is a success log message with green color")
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/menciis/logx.git
git@gitee.com:menciis/logx.git
menciis
logx
logx
master

搜索帮助