You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go-zero/example/logging/logging.go

31 lines
626 B
Go

4 years ago
package main
import (
"time"
"github.com/tal-tech/go-zero/core/logx"
4 years ago
)
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()
}