-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
52 lines (44 loc) · 1.13 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
52
package main
import (
"encoding/json"
"go.uber.org/zap"
// Import your OTEL packages here for instrumentation.
// The default packages are for manual instrumentation, but you can use
// auto-instrumentation packages to capture communication at the edge.
// For more information see https://opentelemetry.io/docs/languages/go/getting-started/
//"go.opentelemetry.io/otel"
//"go.opentelemetry.io/otel/trace"
//"go.opentelemetry.io/otel/exporters/otlp/otlptrace"
)
var (
logger *zap.Logger
)
func init() {
var err error
rawJSON := []byte(`{
"level": "debug",
"encoding": "json",
"outputPaths": ["stdout"],
"errorOutputPaths": ["stderr"],
"initialFields": {"service": "go-template"},
"encoderConfig": {
"messageKey": "message",
"levelKey": "level",
"levelEncoder": "lowercase"
}
}
`)
var cfg zap.Config
if err = json.Unmarshal(rawJSON, &cfg); err != nil {
panic(err)
}
logger = zap.Must(cfg.Build())
defer func() {
if err := logger.Sync(); err != nil {
return
}
}()
}
func main() {
logger.Info("Hello World!")
}