@@ -26,9 +26,13 @@ import (
2626
2727var logger = grpclog .Component ("channelz" )
2828
29+ func withParens (id * Identifier ) string {
30+ return "[" + id .String () + "] "
31+ }
32+
2933// Info logs and adds a trace event if channelz is on.
3034func Info (l grpclog.DepthLoggerV2 , id * Identifier , args ... interface {}) {
31- msg := "[" + id . String () + "] " + fmt .Sprint (args ... )
35+ msg := withParens ( id ) + fmt .Sprint (args ... )
3236 if IsOn () {
3337 AddTraceEvent (l , id , 1 , & TraceEventDesc {
3438 Desc : msg ,
@@ -41,7 +45,7 @@ func Info(l grpclog.DepthLoggerV2, id *Identifier, args ...interface{}) {
4145
4246// Infof logs and adds a trace event if channelz is on.
4347func Infof (l grpclog.DepthLoggerV2 , id * Identifier , format string , args ... interface {}) {
44- msg := "[" + id . String () + "] " + fmt .Sprintf (format , args ... )
48+ msg := withParens ( id ) + fmt .Sprintf (format , args ... )
4549 if IsOn () {
4650 AddTraceEvent (l , id , 1 , & TraceEventDesc {
4751 Desc : msg ,
@@ -54,7 +58,7 @@ func Infof(l grpclog.DepthLoggerV2, id *Identifier, format string, args ...inter
5458
5559// Warning logs and adds a trace event if channelz is on.
5660func Warning (l grpclog.DepthLoggerV2 , id * Identifier , args ... interface {}) {
57- msg := "[" + id . String () + "] " + fmt .Sprint (args ... )
61+ msg := withParens ( id ) + fmt .Sprint (args ... )
5862 if IsOn () {
5963 AddTraceEvent (l , id , 1 , & TraceEventDesc {
6064 Desc : msg ,
@@ -67,7 +71,7 @@ func Warning(l grpclog.DepthLoggerV2, id *Identifier, args ...interface{}) {
6771
6872// Warningf logs and adds a trace event if channelz is on.
6973func Warningf (l grpclog.DepthLoggerV2 , id * Identifier , format string , args ... interface {}) {
70- msg := "[" + id . String () + "] " + fmt .Sprintf (format , args ... )
74+ msg := withParens ( id ) + fmt .Sprintf (format , args ... )
7175 if IsOn () {
7276 AddTraceEvent (l , id , 1 , & TraceEventDesc {
7377 Desc : msg ,
@@ -80,7 +84,7 @@ func Warningf(l grpclog.DepthLoggerV2, id *Identifier, format string, args ...in
8084
8185// Error logs and adds a trace event if channelz is on.
8286func Error (l grpclog.DepthLoggerV2 , id * Identifier , args ... interface {}) {
83- msg := "[" + id . String () + "] " + fmt .Sprint (args ... )
87+ msg := withParens ( id ) + fmt .Sprint (args ... )
8488 if IsOn () {
8589 AddTraceEvent (l , id , 1 , & TraceEventDesc {
8690 Desc : msg ,
@@ -93,7 +97,7 @@ func Error(l grpclog.DepthLoggerV2, id *Identifier, args ...interface{}) {
9397
9498// Errorf logs and adds a trace event if channelz is on.
9599func Errorf (l grpclog.DepthLoggerV2 , id * Identifier , format string , args ... interface {}) {
96- msg := "[" + id . String () + "] " + fmt .Sprintf (format , args ... )
100+ msg := withParens ( id ) + fmt .Sprintf (format , args ... )
97101 if IsOn () {
98102 AddTraceEvent (l , id , 1 , & TraceEventDesc {
99103 Desc : msg ,
0 commit comments