-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
36 lines (27 loc) · 800 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
package main
import (
"context"
"errors"
"log"
"os"
"github.com/elgopher/yala/adapter/logadapter"
"github.com/elgopher/yala/logger"
)
var ErrSome = errors.New("ErrSome")
// This example shows how to use yala with standard `log` package
func main() {
ctx := context.Background()
// log using standard log package
standardLog := log.New(os.Stdout, "", log.LstdFlags|log.Lshortfile)
adapter := logadapter.Adapter(standardLog)
yalaLogger := logger.WithAdapter(adapter)
yalaLogger.Debug(ctx, "Hello standard log")
yalaLogger.InfoFields(ctx, "Some info", logger.Fields{
"f1": "v1",
"f2": "v2",
})
yalaLogger.WarnFields(ctx, "Deprecated configuration parameter. It will be removed.", logger.Fields{
"parameter": "some",
})
yalaLogger.ErrorCause(ctx, "Some error", ErrSome)
}