package xlog import ( "fmt" "log" jsoniter "github.com/json-iterator/go" ) // XLog 日志接口 type XLog interface{} // These functions write to the standard logger. // Print calls Output to print to the standard logger. // Arguments are handled in the manner of fmt.Print. func Print(v ...interface{}) { log.Output(2, fmt.Sprint(v...)) } // Printf calls Output to print to the standard logger. // Arguments are handled in the manner of fmt.Printf. func Printf(format string, v ...interface{}) { log.Output(2, fmt.Sprintf(format, v...)) } // Println calls Output to print to the standard logger. // Arguments are handled in the manner of fmt.Println. func Println(v ...interface{}) { content, err := jsoniter.Marshal(v) if err != nil { log.Output(2, fmt.Sprintln(v...)) } log.Output(2, string(content)) } // Fatalf is equivalent to Printf() followed by a call to os.Exit(1). func Fatalf(format string, v ...interface{}) { log.Fatalf(format, v...) }