change g.SetDebug function to control the debugging information for framework

This commit is contained in:
John
2020-09-24 23:40:44 +08:00
parent da43c2d52f
commit a5e3e2f5ba
4 changed files with 18 additions and 9 deletions

View File

@ -56,8 +56,10 @@ func (m *Model) Data(data ...interface{}) *Model {
case Map:
model.data = params
default:
rv := reflect.ValueOf(params)
kind := rv.Kind()
var (
rv = reflect.ValueOf(params)
kind = rv.Kind()
)
if kind == reflect.Ptr {
rv = rv.Elem()
kind = rv.Kind()

View File

@ -10,17 +10,14 @@ import (
"github.com/gogf/gf/os/glog"
)
// SetDebug disables/enables debug level for logging component globally.
func SetDebug(debug bool) {
glog.SetDebug(debug)
}
// SetLogLevel sets the logging level globally.
// Deprecated, use functions of package glog or g.Log() instead.
func SetLogLevel(level int) {
glog.SetLevel(level)
}
// GetLogLevel returns the global logging level.
// Deprecated, use functions of package glog or g.Log() instead.
func GetLogLevel() int {
return glog.GetLevel()
}

View File

@ -6,7 +6,17 @@
package g
import "github.com/gogf/gf/net/ghttp"
import (
"github.com/gogf/gf/internal/intlog"
"github.com/gogf/gf/net/ghttp"
)
// SetEnabled enables/disables the GoFrame internal logging manually.
// Note that this function is not concurrent safe, be aware of the DATA RACE,
// which means you should call this function in your boot but not the runtime.
func SetDebug(enabled bool) {
intlog.SetEnabled(enabled)
}
// SetServerGraceful enables/disables graceful reload feature of http Web Server.
// This feature is disabled in default.

View File

@ -33,7 +33,7 @@ func init() {
}
// SetEnabled enables/disables the internal logging manually.
// Note that this function is not current safe, be aware of the DATA RACE.
// Note that this function is not concurrent safe, be aware of the DATA RACE.
func SetEnabled(enabled bool) {
isGFDebug = enabled
}