1 Star 0 Fork 0

瑞哥/util

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
PrintPlus.go 1.82 KB
一键复制 编辑 原始数据 按行查看 历史
瑞哥 提交于 2023-03-04 23:26 . 更新到go1.20.x
package rlog
import "fmt"
type _configPlus struct {
_config *_config
printConsoleOnly byte
printFileOnly byte
}
// ConsoleOnly 只打印控制台日志
func (c *_config) ConsoleOnly() *_configPlus {
return &_configPlus{
_config: c,
printConsoleOnly: 1,
printFileOnly: 0,
}
}
// FileOnly 只打印文件日志
func (c *_config) FileOnly() *_configPlus {
return &_configPlus{
_config: c,
printConsoleOnly: 0,
printFileOnly: 1,
}
}
// DoNotPrint 不打印任何日志
func (c *_config) DoNotPrint() *_configPlus {
return &_configPlus{
_config: c,
printConsoleOnly: 0,
printFileOnly: 0,
}
}
func (c *_configPlus) Print(a ...any) {
c._config.content(fmt.Sprint(a...), tagPrint, c.printConsoleOnly, c.printFileOnly)
}
func (c *_configPlus) Println(a ...any) {
c._config.content(fmt.Sprintln(a...), tagPrint, c.printConsoleOnly, c.printFileOnly)
}
func (c *_configPlus) Printf(format string, a ...any) {
c._config.content(fmt.Sprint(append([]any{format}, a...)), tagPrint, c.printConsoleOnly, c.printFileOnly)
}
func (c *_configPlus) Debug(a ...any) {
c._config.content(fmt.Sprintln(a...), tagDebug, c.printConsoleOnly, c.printFileOnly)
}
func (c *_configPlus) Info(a ...any) {
c._config.content(fmt.Sprintln(a...), tagInfo, c.printConsoleOnly, c.printFileOnly)
}
func (c *_configPlus) Success(a ...any) {
c._config.content(fmt.Sprintln(a...), tagSuccess, c.printConsoleOnly, c.printFileOnly)
}
func (c *_configPlus) Warn(a ...any) {
c._config.content(fmt.Sprintln(a...), tagWarn, c.printConsoleOnly, c.printFileOnly)
}
func (c *_configPlus) Error(a ...any) {
c._config.content(fmt.Sprintln(a...), tagError, c.printConsoleOnly, c.printFileOnly)
}
func (c *_configPlus) Panic(a ...any) {
c._config.content(fmt.Sprintln(a...), tagPanic, c.printConsoleOnly, c.printFileOnly)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/ruige_fun/util.git
git@gitee.com:ruige_fun/util.git
ruige_fun
util
util
v0.0.32

搜索帮助