goProject/.svn/pristine/8a/8abf2d01144747bd0f94d996b4042ef26f184531.svn-base
2025-01-06 16:21:36 +08:00

67 lines
1.6 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package debugUtil
import (
"github.com/fatih/color"
)
var (
isDebug = false
code Code = Code_Bold
foregroundColor ForegroundColor = Foreground_Purple
backgroundColor BackgroundColor = BackgroundColor_Black
colorObj = color.New(foregroundColor, code)
)
// 设置DEBUG状态
// _isDebug是否是DEBUG
func SetDebug(_isDebug bool) {
isDebug = _isDebug
}
// 是否处于调试状态
func IsDebug() bool {
return isDebug
}
// 设置显示信息
func SetDisplayInfo(_code Code, _foregroundColor ForegroundColor, _backgroundColor BackgroundColor) {
code = _code
foregroundColor = _foregroundColor
backgroundColor = _backgroundColor
colorObj = color.New(foregroundColor, code)
}
// Print formats using the default formats for its operands and writes to standard output.
// Spaces are added between operands when neither is a string.
// It returns the number of bytes written and any write error encountered.
func Print(a ...interface{}) {
if !isDebug {
return
}
_, _ = colorObj.Print(a...)
}
// Printf formats according to a format specifier and writes to standard output.
// It returns the number of bytes written and any write error encountered.
func Printf(format string, a ...interface{}) {
if !isDebug {
return
}
_, _ = colorObj.Printf(format, a...)
}
// Println formats using the default formats for its operands and writes to standard output.
// Spaces are always added between operands and a newline is appended.
// It returns the number of bytes written and any write error encountered.
func Println(a ...interface{}) {
if !isDebug {
return
}
_, _ = colorObj.Println(a...)
}