-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
34 lines (25 loc) · 839 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
package main
import (
"context"
"errors"
"github.com/elgopher/yala/adapter/log15adapter"
"github.com/elgopher/yala/logger"
"github.com/inconshreveable/log15"
)
var ErrSome = errors.New("some error")
// This example shows how to use yala with log15 adapter
func main() {
ctx := context.Background()
l := log15.New() // create log15 logger
adapter := log15adapter.Adapter{Logger: l} // create logger.Adapter for log15
log := logger.WithAdapter(adapter) // create yala logger
log.Debug(ctx, "Hello log15")
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)
}