go-zero/example/logging/logging.go

31 lines
626 B
Go
Raw Normal View History

2020-07-26 17:09:05 +08:00
package main
import (
"time"
2020-08-08 16:40:10 +08:00
"github.com/tal-tech/go-zero/core/logx"
2020-07-26 17:09:05 +08:00
)
func foo() {
logx.WithDuration(time.Second).Error("world")
}
func main() {
c := logx.LogConf{
Mode: "console",
Path: "logs",
}
logx.MustSetup(c)
defer logx.Close()
logx.Info("info")
logx.Error("error")
logx.ErrorStack("hello")
logx.Errorf("%s and %s", "hello", "world")
logx.Severef("%s severe %s", "hello", "world")
logx.Slowf("%s slow %s", "hello", "world")
logx.Statf("%s stat %s", "hello", "world")
logx.WithDuration(time.Minute + time.Second).Info("hello")
logx.WithDuration(time.Minute + time.Second).Error("hello")
foo()
}