Apply .gitignore rules
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
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...)
|
||||
}
|
||||
Reference in New Issue
Block a user