File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ import (
31
31
32
32
// EnableTracing controls whether to trace RPCs using the golang.org/x/net/trace package.
33
33
// This should only be set before any RPCs are sent or received by this program.
34
- var EnableTracing = true
34
+ var EnableTracing bool
35
35
36
36
// methodFamily returns the trace family for the given method.
37
37
// It turns "/pkg.Service/GetFoo" into "pkg.Service".
@@ -76,6 +76,15 @@ func (f *firstLine) String() string {
76
76
return line .String ()
77
77
}
78
78
79
+ const truncateSize = 100
80
+
81
+ func truncate (x string , l int ) string {
82
+ if l > len (x ) {
83
+ return x
84
+ }
85
+ return x [:l ]
86
+ }
87
+
79
88
// payload represents an RPC request or response payload.
80
89
type payload struct {
81
90
sent bool // whether this is an outgoing payload
@@ -85,9 +94,9 @@ type payload struct {
85
94
86
95
func (p payload ) String () string {
87
96
if p .sent {
88
- return fmt .Sprintf ("sent: %v" , p .msg )
97
+ return truncate ( fmt .Sprintf ("sent: %v" , p .msg ), truncateSize )
89
98
}
90
- return fmt .Sprintf ("recv: %v" , p .msg )
99
+ return truncate ( fmt .Sprintf ("recv: %v" , p .msg ), truncateSize )
91
100
}
92
101
93
102
type fmtStringer struct {
You can’t perform that action at this time.
0 commit comments