add gf.debug options and GF_DEBUG env control params for internal logging feature

This commit is contained in:
John
2020-02-22 14:51:44 +08:00
parent 745a913cfb
commit d8ef8a1f5d
4 changed files with 15 additions and 13 deletions

View File

@ -20,26 +20,26 @@ const (
)
var (
// isInGFDevelop marks whether current environment is in GF development.
isInGFDevelop = false
// isGFDebug marks whether printing GoFrame debug information.
isGFDebug = false
)
func init() {
if !cmdenv.Get("GF_DEV").IsEmpty() {
isInGFDevelop = true
if !cmdenv.Get("GF_DEBUG").IsEmpty() {
isGFDebug = true
return
}
}
// IsInGFDevelop checks and returns whether current process is in GF development.
func IsInGFDevelop() bool {
return isInGFDevelop
// IsGFDebug checks and returns whether current process is in GF development.
func IsGFDebug() bool {
return isGFDebug
}
// Print prints <v> with newline using fmt.Println.
// The parameter <v> can be multiple variables.
func Print(v ...interface{}) {
if !isInGFDevelop {
if !isGFDebug {
return
}
fmt.Println(append([]interface{}{now(), "[INTE]", file()}, v...)...)
@ -48,7 +48,7 @@ func Print(v ...interface{}) {
// Printf prints <v> with format <format> using fmt.Printf.
// The parameter <v> can be multiple variables.
func Printf(format string, v ...interface{}) {
if !isInGFDevelop {
if !isGFDebug {
return
}
fmt.Printf(now()+" [INTE] "+file()+" "+format+"\n", v...)
@ -57,7 +57,7 @@ func Printf(format string, v ...interface{}) {
// Error prints <v> with newline using fmt.Println.
// The parameter <v> can be multiple variables.
func Error(v ...interface{}) {
if !isInGFDevelop {
if !isGFDebug {
return
}
array := append([]interface{}{now(), "[INTE]", file()}, v...)
@ -67,7 +67,7 @@ func Error(v ...interface{}) {
// Errorf prints <v> with format <format> using fmt.Printf.
func Errorf(format string, v ...interface{}) {
if !isInGFDevelop {
if !isGFDebug {
return
}
fmt.Printf(