package Util import ( "Mmx/Global" "fmt" "log" "reflect" "time" ) type loG struct { timeStamp string } var Log loG func (*loG) WriteLog(name string, a ...interface{}) { for _, v := range a { var t string switch reflect.TypeOf(v).Kind() { case reflect.String: t = v.(string) case reflect.Interface: t = v.(error).Error() default: t = fmt.Sprint(v) } _ = File.Add(name, t) } } func (c *loG) genTimeStamp() { if c.timeStamp == "" { c.timeStamp = time.Now().Format("2006.01.02-15:04:05") } } func (c *loG) Println(a ...interface{}) { c.genTimeStamp() if Global.Config.Settings.DemoMode { c.WriteLog("Login-"+c.timeStamp+".log", a...) } log.Println(a...) } func (c *loG) Fatalln(a ...interface{}) { c.genTimeStamp() c.WriteLog("LoginError-"+c.timeStamp+".log", a...) log.Fatalln(a...) }