diff --git a/lego/sys/log/options.go b/lego/sys/log/options.go index a0c5e8815..0073a56c5 100644 --- a/lego/sys/log/options.go +++ b/lego/sys/log/options.go @@ -102,7 +102,7 @@ func newOptions(config map[string]interface{}, opts ...Option) (options *Options MaxBackups: 250, Compress: false, Encoder: TextEncoder, - CallerSkip: 0, + CallerSkip: 3, ReportCaller: ErrorLevel, IsDebug: true, } @@ -128,7 +128,7 @@ func newOptionsByOption(opts ...Option) (options *Options, err error) { MaxBackups: 250, Compress: false, Encoder: TextEncoder, - CallerSkip: 0, + CallerSkip: 3, ReportCaller: ErrorLevel, IsDebug: true, } diff --git a/lego/utils/codec/json/json_test.go b/lego/utils/codec/json/json_test.go new file mode 100644 index 000000000..f3552f843 --- /dev/null +++ b/lego/utils/codec/json/json_test.go @@ -0,0 +1,38 @@ +package json_test + +import ( + "fmt" + "go_dreamfactory/lego/utils/codec/json" + "testing" +) + +type TestData struct { + Name string + Age int + List []string + Map map[string]interface{} +} + +//测试api_getlist +func Test_Json_Write(t *testing.T) { + ret, err := json.MarshalMap(&TestData{ + Name: "liwei", + Age: 10, + List: []string{"123", "456", "789"}, + Map: map[string]interface{}{ + "aa": 123, + "b": "123123", + }, + }) + fmt.Printf("ret:%v err:%v", ret, err) + ret, err = json.MarshalMap(&TestData{ + Name: "asdasd", + Age: 10, + List: []string{"12asd3", "45sdaa6", "asdasd"}, + Map: map[string]interface{}{ + "asd": 586, + "asdasd": "asd1231", + }, + }) + fmt.Printf("ret:%v err:%v", ret, err) +} diff --git a/modules/options.go b/modules/options.go index c2479d720..2922bb262 100644 --- a/modules/options.go +++ b/modules/options.go @@ -33,7 +33,7 @@ func (this *Options) LoadConfig(settings map[string]interface{}) (err error) { err = mapstructure.Decode(settings, this) } - if this.Log = log.NewTurnlog(this.Debug, log.Clone("", 2)); this.Log == nil { + if this.Log = log.NewTurnlog(this.Debug, log.Clone("", 3)); this.Log == nil { err = errors.New("log is nil") } return diff --git a/sys/db/dbconn.go b/sys/db/dbconn.go index f778f174c..02da6a53e 100644 --- a/sys/db/dbconn.go +++ b/sys/db/dbconn.go @@ -190,7 +190,7 @@ func (this *DBModel) AddLists(uid string, data interface{}, opt ...DBOption) (er } listskeys := make(map[string]string) keys := vof.MapKeys() - lists := make([]interface{}, len(keys)) + lists := make([]interface{}, 0, len(keys)) pipe := this.Redis.RedisPipe(context.TODO()) for _, k := range keys { value := vof.MapIndex(k) @@ -199,6 +199,7 @@ func (this *DBModel) AddLists(uid string, data interface{}, opt ...DBOption) (er key := this.ukeylist(uid, keydata) pipe.HMSet(key, valuedata) listskeys[keydata] = key + lists = append(lists, valuedata) } pipe.HMSetForMap(this.ukey(uid), listskeys) if _, err = pipe.Exec(); err != nil {