-
Notifications
You must be signed in to change notification settings - Fork 84
/
Copy pathinterface_with_log.go
executable file
·86 lines (76 loc) · 2.9 KB
/
interface_with_log.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
// Code generated by gowrap. DO NOT EDIT.
// template: ../templates/log
// gowrap: http://github.com/hexdigest/gowrap
package templatestests
//go:generate gowrap gen -p github.com/hexdigest/gowrap/templates_tests -i TestInterface -t ../templates/log -o interface_with_log.go -v DecoratorName=TestInterfaceWithLogger -l ""
import (
"context"
"io"
"log"
)
// TestInterfaceWithLogger implements TestInterface that is instrumented with logging
type TestInterfaceWithLogger struct {
_stdlog, _errlog *log.Logger
_base TestInterface
}
// NewTestInterfaceWithLogger instruments an implementation of the TestInterface with simple logging
func NewTestInterfaceWithLogger(base TestInterface, stdout, stderr io.Writer) TestInterfaceWithLogger {
return TestInterfaceWithLogger{
_base: base,
_stdlog: log.New(stdout, "", log.LstdFlags),
_errlog: log.New(stderr, "", log.LstdFlags),
}
}
// Channels implements TestInterface
func (_d TestInterfaceWithLogger) Channels(chA chan bool, chB chan<- bool, chanC <-chan bool) {
_params := []interface{}{"TestInterfaceWithLogger: calling Channels with params:", chA, chB, chanC}
_d._stdlog.Println(_params...)
defer func() {
_d._stdlog.Println("TestInterfaceWithLogger: Channels finished")
}()
_d._base.Channels(chA, chB, chanC)
return
}
// ContextNoError implements TestInterface
func (_d TestInterfaceWithLogger) ContextNoError(ctx context.Context, a1 string, a2 string) {
_params := []interface{}{"TestInterfaceWithLogger: calling ContextNoError with params:", ctx, a1, a2}
_d._stdlog.Println(_params...)
defer func() {
_d._stdlog.Println("TestInterfaceWithLogger: ContextNoError finished")
}()
_d._base.ContextNoError(ctx, a1, a2)
return
}
// F implements TestInterface
func (_d TestInterfaceWithLogger) F(ctx context.Context, a1 string, a2 ...string) (result1 string, result2 string, err error) {
_params := []interface{}{"TestInterfaceWithLogger: calling F with params:", ctx, a1, a2}
_d._stdlog.Println(_params...)
defer func() {
_results := []interface{}{"TestInterfaceWithLogger: F returned results:", result1, result2, err}
if err != nil {
_d._errlog.Println(_results...)
} else {
_d._stdlog.Println(_results...)
}
}()
return _d._base.F(ctx, a1, a2...)
}
// NoError implements TestInterface
func (_d TestInterfaceWithLogger) NoError(s1 string) (s2 string) {
_params := []interface{}{"TestInterfaceWithLogger: calling NoError with params:", s1}
_d._stdlog.Println(_params...)
defer func() {
_results := []interface{}{"TestInterfaceWithLogger: NoError returned results:", s2}
_d._stdlog.Println(_results...)
}()
return _d._base.NoError(s1)
}
// NoParamsOrResults implements TestInterface
func (_d TestInterfaceWithLogger) NoParamsOrResults() {
_d._stdlog.Println("TestInterfaceWithLogger: calling NoParamsOrResults")
defer func() {
_d._stdlog.Println("TestInterfaceWithLogger: NoParamsOrResults finished")
}()
_d._base.NoParamsOrResults()
return
}