-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
51 lines (41 loc) · 1.12 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
//"github.com/micro/go-micro/v2/util/log"
"os"
"github.com/micro/go-micro/v2"
log "github.com/micro/go-micro/v2/logger"
"github.com/micro/go-plugins/logger/zerolog/v2"
"gitlab.com/krayohu/logtest/handler"
"gitlab.com/krayohu/logtest/subscriber"
logtest "gitlab.com/krayohu/logtest/proto/logtest"
)
func main() {
// Setup log
log.DefaultLogger = zerolog.NewLogger(
log.WithOutput(os.Stdout),
log.WithLevel(log.DebugLevel),
zerolog.ReportCaller(),
//zerolog.ReportCallerWithCount(4),
zerolog.WithDevelopmentMode(),
//zerolog.WithProductionMode(),
)
// New Service
service := micro.NewService(
micro.Name("go.micro.srv.logtest"),
micro.Version("latest"),
)
// Initialise service
service.Init()
log.Info("Info")
log.Debug("Debug")
log.Error("Error")
log.Log(log.InfoLevel, "Log Info")
// Register Handler
logtest.RegisterLogtestHandler(service.Server(), new(handler.Logtest))
// Register Struct as Subscriber
micro.RegisterSubscriber("ps.clientele.svc.logtest", service.Server(), new(subscriber.Logtest))
// Run service
if err := service.Run(); err != nil {
log.Fatal(err)
}
}