package galog

import (
	"testing"
	"time"
)

var slogger *Logger

// go test -bench . -benchmem
func init() {
	slogger, _ = NewServerLogger(&ServerLogOptions{
		LogDir:      "logs",
		EnableAsync: true,
	})
}

// BenchmarkServerLog-8   	  436682	      3103 ns/op	    1838 B/op	      24 allocs/op
func BenchmarkServerLog(b *testing.B) {
	for i := 0; i < b.N; i++ {
		msgMap := map[string]interface{}{
			"CreateTime": time.Now().UnixNano() / int64(time.Microsecond),
			"Host":       "host",
			"AppId":      "10010",
			"UserId":     "12345",
			"Level":      "Notice",
			"Entry":      "Login",
			"Func":       "HandleLogin",
			"TraceMsg":   "HandlerWSFriApplyList|HandlerWSFriApplyList",
			"Params":     "{\"isoCode\":\"CN\",\"P0\":[3,\"Total: 3, End: 0, \"],\"pf\":\"wx\",\"appVer\":\"1.0\",\"sdkVer\":\"1.0\",\"ip\":\"58.247.195.158\",\"clientId\":\"7abd64bf-3fb6-4fef-a25e-e6562b7fb857\",\"timeZone\":\"Asia/Shanghai\",\"loginMark\":\"\",\"st\":1472}",
		}
		slogger.BizErr(msgMap)
	}
}
