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.
This commit is contained in:
@ -42,6 +42,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Use golang's standard logger by default.
|
// Use golang's standard logger by default.
|
||||||
|
// Access is not mutex-protected: do not modify except in init()
|
||||||
|
// functions.
|
||||||
var logger Logger = log.New(os.Stderr, "", log.LstdFlags)
|
var logger Logger = log.New(os.Stderr, "", log.LstdFlags)
|
||||||
|
|
||||||
// Logger mimics golang's standard Logger as an interface.
|
// Logger mimics golang's standard Logger as an interface.
|
||||||
@ -54,7 +56,8 @@ type Logger interface {
|
|||||||
Println(args ...interface{})
|
Println(args ...interface{})
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetLogger sets the logger that is used in grpc.
|
// SetLogger sets the logger that is used in grpc. Call only from
|
||||||
|
// init() functions.
|
||||||
func SetLogger(l Logger) {
|
func SetLogger(l Logger) {
|
||||||
logger = l
|
logger = l
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user