-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
45 lines (37 loc) · 1000 Bytes
/
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
package main
import (
"fmt"
"log"
"os"
"time"
"go.uber.org/zap"
)
// RegisterCoralogixSink registers a new sink, and returns the output path
func RegisterCoralogixSink(key string) string {
coralogixSink := NewCoralogixZapSinkFactory(key, "testApp", "testSubSys")
err := zap.RegisterSink(CORALOGIX_SINK_SCHEME, coralogixSink)
if err != nil {
panic(err)
}
return fmt.Sprintf("%s:", CORALOGIX_SINK_SCHEME)
}
func CreateLogger() *zap.Logger {
coralogixPrivateKey := os.Getenv("CORALOGIX_PRIVATE_KEY")
coralogixOutputPath := RegisterCoralogixSink(coralogixPrivateKey)
loggerConfig := zap.NewProductionConfig()
loggerConfig.OutputPaths = append(loggerConfig.OutputPaths, coralogixOutputPath)
logger, err := loggerConfig.Build()
if err != nil {
log.Fatal(err)
}
return logger
}
func main() {
logger := CreateLogger()
defer logger.Sync()
logger.Info("failed to fetch URL",
zap.String("hello", "world"),
zap.Int("attempt", 3),
zap.Duration("backoff", time.Second),
)
}