From a5e3e2f5ba6422d09f718d005689400f7416d374 Mon Sep 17 00:00:00 2001 From: John Date: Thu, 24 Sep 2020 23:40:44 +0800 Subject: [PATCH] change g.SetDebug function to control the debugging information for framework --- database/gdb/gdb_model_insert.go | 6 ++++-- frame/g/g_logger.go | 7 ++----- frame/g/g_setting.go | 12 +++++++++++- internal/intlog/intlog.go | 2 +- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/database/gdb/gdb_model_insert.go b/database/gdb/gdb_model_insert.go index ded9542a7..358ce6f7c 100644 --- a/database/gdb/gdb_model_insert.go +++ b/database/gdb/gdb_model_insert.go @@ -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() diff --git a/frame/g/g_logger.go b/frame/g/g_logger.go index cc2e11598..280162e97 100644 --- a/frame/g/g_logger.go +++ b/frame/g/g_logger.go @@ -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() } diff --git a/frame/g/g_setting.go b/frame/g/g_setting.go index 20b5b4573..d989adaf1 100644 --- a/frame/g/g_setting.go +++ b/frame/g/g_setting.go @@ -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. diff --git a/internal/intlog/intlog.go b/internal/intlog/intlog.go index 24d05d539..4c44c62fd 100644 --- a/internal/intlog/intlog.go +++ b/internal/intlog/intlog.go @@ -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 }