Skip to content

Commit 58a5c4c

Browse files
Elliot ForbesElliot Forbes
authored andcommitted
Adding more wrappers
1 parent a6abd90 commit 58a5c4c

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

error.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
package ctxlog
22

3-
import "context"
3+
import (
4+
"context"
5+
6+
"github.com/sirupsen/logrus"
7+
)
48

59
func (l *CtxLogger) Error(ctx context.Context, msg string) {
610
fields := convertFieldsToLogrusFields(getFields(ctx))
711
l.Log.WithFields(fields).Error(msg)
812
}
13+
14+
func (l *CtxLogger) ErrorFn(ctx context.Context, logFunc logrus.LogFunction) {
15+
fields := convertFieldsToLogrusFields(getFields(ctx))
16+
l.Log.WithFields(fields).Logger.ErrorFn(logFunc)
17+
}

info.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,16 @@ package ctxlog
22

33
import (
44
"context"
5+
6+
"github.com/sirupsen/logrus"
57
)
68

79
func (l *CtxLogger) Info(ctx context.Context, msg string) {
810
fields := convertFieldsToLogrusFields(getFields(ctx))
911
l.Log.WithFields(fields).Info(msg)
1012
}
13+
14+
func (l *CtxLogger) InfoFn(ctx context.Context, logFun logrus.LogFunction) {
15+
fields := convertFieldsToLogrusFields(getFields(ctx))
16+
l.Log.WithFields(fields).InfoFn(logFun)
17+
}

warn.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
package ctxlog
22

3-
import "context"
3+
import (
4+
"context"
5+
6+
"github.com/sirupsen/logrus"
7+
)
48

59
func (l *CtxLogger) Warn(ctx context.Context, msg string) {
610
fields := convertFieldsToLogrusFields(getFields(ctx))
711
l.Log.WithFields(fields).Warn(msg)
812
}
13+
14+
func (l *CtxLogger) Warn(ctx context.Context, logFunc logrus.LogFunction) {
15+
fields := convertFieldsToLogrusFields(getFields(ctx))
16+
l.Log.WithFields(fields).WarnFn(logFunc)
17+
}

0 commit comments

Comments
 (0)