Skip to content

Commit 65e7361

Browse files
committed
Comment: explain concurrent access to grpclog.logger
grpc's pluggable logger is not mutex-protected: added comments that it should be changed only in init() functions.
1 parent 93591e7 commit 65e7361

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

grpclog/logger.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ import (
4242
)
4343

4444
// Use golang's standard logger by default.
45+
// Access is not mutex-protected: do not modify except in init()
46+
// functions.
4547
var logger Logger = log.New(os.Stderr, "", log.LstdFlags)
4648

4749
// Logger mimics golang's standard Logger as an interface.
@@ -54,7 +56,8 @@ type Logger interface {
5456
Println(args ...interface{})
5557
}
5658

57-
// SetLogger sets the logger that is used in grpc.
59+
// SetLogger sets the logger that is used in grpc. Call only from
60+
// init() functions.
5861
func SetLogger(l Logger) {
5962
logger = l
6063
}

0 commit comments

Comments
 (0)