-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.go
66 lines (57 loc) · 1.87 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package main
import (
"context"
"errors"
"log/slog"
"os"
"github.com/osbuild/logging/pkg/logrus"
)
func main() {
ctx := context.Background()
slog.SetDefault(slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{Level: slog.LevelDebug})))
logrus.SetDefault(logrus.NewProxy())
logrus.Println("print")
logrus.Traceln("trace")
logrus.Debugln("debug")
logrus.Infoln("info")
logrus.Warnln("warn")
logrus.Errorln("error")
logrus.Panicln("panic")
logrus.Print("a", "b", "c")
logrus.Trace("a", "b", "c")
logrus.Debug("a", "b", "c")
logrus.Info("a", "b", "c")
logrus.Warn("a", "b", "c")
logrus.Warning("a", "b", "c")
logrus.Error("a", "b", "c")
logrus.Panic("a", "b", "c")
logrus.Printf("number: %d", 42)
logrus.Tracef("number: %d", 42)
logrus.Debugf("number: %d", 42)
logrus.Infof("number: %d", 42)
logrus.Warnf("number: %d", 42)
logrus.Warningf("number: %d", 42)
logrus.Errorf("number: %d", 42)
logrus.Panicf("number: %d", 42)
logrus.WithContext(ctx).Print("msg with context")
logrus.WithContext(ctx).Trace("msg with context")
logrus.WithContext(ctx).Debug("msg with context")
logrus.WithContext(ctx).Info("msg with context")
logrus.WithContext(ctx).Warn("msg with context")
logrus.WithContext(ctx).Error("msg with context")
logrus.WithContext(ctx).Panic("msg with context")
logrus.WithField("key", "value").Print("msg with field")
logrus.WithField("key", "value").Trace("msg with field")
logrus.WithField("key", "value").Debug("msg with field")
logrus.WithField("key", "value").Info("msg with field")
logrus.WithField("key", "value").Warn("msg with field")
logrus.WithField("key", "value").Error("msg with field")
logrus.WithField("key", "value").Panic("msg with field")
logrus.WithError(errors.New("test")).Error("msg with err")
logrus.WithFields(logrus.Fields{
"str": "value",
"int": 42,
"bool": true,
"float": 3.14,
}).Trace("msg with fields")
}