-
Notifications
You must be signed in to change notification settings - Fork 81
/
interface_with_logrus.go
executable file
·96 lines (85 loc) · 3.05 KB
/
interface_with_logrus.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Code generated by gowrap. DO NOT EDIT.
// template: ../templates/logrus
// gowrap: http://github.com/hexdigest/gowrap
package templatestests
//go:generate gowrap gen -p github.com/hexdigest/gowrap/templates_tests -i TestInterface -t ../templates/logrus -o interface_with_logrus.go -l ""
import (
"context"
"github.com/sirupsen/logrus"
)
// TestInterfaceWithLogrus implements TestInterface that is instrumented with logrus logger
type TestInterfaceWithLogrus struct {
_log *logrus.Entry
_base TestInterface
}
// NewTestInterfaceWithLogrus instruments an implementation of the TestInterface with simple logging
func NewTestInterfaceWithLogrus(base TestInterface, log *logrus.Entry) TestInterfaceWithLogrus {
return TestInterfaceWithLogrus{
_base: base,
_log: log,
}
}
// Channels implements TestInterface
func (_d TestInterfaceWithLogrus) Channels(chA chan bool, chB chan<- bool, chanC <-chan bool) {
_d._log.WithFields(logrus.Fields(map[string]interface{}{
"chA": chA,
"chB": chB,
"chanC": chanC})).Debug("TestInterfaceWithLogrus: calling Channels")
defer func() {
_d._log.Debug("TestInterfaceWithLogrus: Channels finished")
}()
_d._base.Channels(chA, chB, chanC)
return
}
// ContextNoError implements TestInterface
func (_d TestInterfaceWithLogrus) ContextNoError(ctx context.Context, a1 string, a2 string) {
_d._log.WithFields(logrus.Fields(map[string]interface{}{
"ctx": ctx,
"a1": a1,
"a2": a2})).Debug("TestInterfaceWithLogrus: calling ContextNoError")
defer func() {
_d._log.Debug("TestInterfaceWithLogrus: ContextNoError finished")
}()
_d._base.ContextNoError(ctx, a1, a2)
return
}
// F implements TestInterface
func (_d TestInterfaceWithLogrus) F(ctx context.Context, a1 string, a2 ...string) (result1 string, result2 string, err error) {
_d._log.WithFields(logrus.Fields(map[string]interface{}{
"ctx": ctx,
"a1": a1,
"a2": a2})).Debug("TestInterfaceWithLogrus: calling F")
defer func() {
if err != nil {
_d._log.WithFields(logrus.Fields(map[string]interface{}{
"result1": result1,
"result2": result2,
"err": err})).Error("TestInterfaceWithLogrus: method F returned an error")
} else {
_d._log.WithFields(logrus.Fields(map[string]interface{}{
"result1": result1,
"result2": result2,
"err": err})).Debug("TestInterfaceWithLogrus: method F finished")
}
}()
return _d._base.F(ctx, a1, a2...)
}
// NoError implements TestInterface
func (_d TestInterfaceWithLogrus) NoError(s1 string) (s2 string) {
_d._log.WithFields(logrus.Fields(map[string]interface{}{
"s1": s1})).Debug("TestInterfaceWithLogrus: calling NoError")
defer func() {
_d._log.WithFields(logrus.Fields(map[string]interface{}{
"s2": s2})).Debug("TestInterfaceWithLogrus: method NoError finished")
}()
return _d._base.NoError(s1)
}
// NoParamsOrResults implements TestInterface
func (_d TestInterfaceWithLogrus) NoParamsOrResults() {
_d._log.Debug("TestInterfaceWithLogrus: calling NoParamsOrResults")
defer func() {
_d._log.Debug("TestInterfaceWithLogrus: NoParamsOrResults finished")
}()
_d._base.NoParamsOrResults()
return
}