mirror of
https://gitee.com/johng/gf
synced 2026-06-07 02:12:11 +08:00
add gf.debug options and GF_DEBUG env control params for internal logging feature
This commit is contained in:
@ -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(
|
||||
|
||||
Reference in New Issue
Block a user