-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
35 lines (26 loc) · 847 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
package main
import (
"context"
"errors"
"os"
"github.com/elgopher/yala/adapter/zerologadapter"
"github.com/elgopher/yala/logger"
"github.com/rs/zerolog"
)
var ErrSome = errors.New("ErrSome")
// This example shows how to use yala with zerolog adapter
func main() {
ctx := context.Background()
l := zerolog.New(os.Stdout) // create zerolog logger
adapter := zerologadapter.Adapter{Logger: l} // create logger.Adapter for zerolog
log := logger.WithAdapter(adapter) // Create yala logger
log.Debug(ctx, "Hello zerolog")
log.InfoFields(ctx, "Some info", logger.Fields{
"field_name": "field_value",
"other_name": "field_value",
})
log.WarnFields(ctx, "Deprecated configuration parameter. It will be removed.", logger.Fields{
"parameter": "some",
})
log.ErrorCause(ctx, "Some error", ErrSome)
}