initial import
This commit is contained in:
30
example/logging/logging.go
Normal file
30
example/logging/logging.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"zero/core/logx"
|
||||
)
|
||||
|
||||
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()
|
||||
}
|
||||
20
example/logging/redirector/main.go
Normal file
20
example/logging/redirector/main.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"zero/core/logx"
|
||||
)
|
||||
|
||||
func main() {
|
||||
logx.MustSetup(logx.LogConf{
|
||||
Mode: "console",
|
||||
})
|
||||
logx.CollectSysLog()
|
||||
|
||||
line := "asdkg"
|
||||
logx.Info(line)
|
||||
fmt.Print(line)
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
Reference in New Issue
Block a user