remotelogger.New
should return a pointer instead of value
#653
-
I'm curious why the function func New(level logging.Level, remoteConfigURL, loggerFetchInterval string) logging.Logger {
interval, err := strconv.Atoi(loggerFetchInterval)
if err != nil {
interval = 15
}
l := remoteLogger{
remoteURL: remoteConfigURL,
Logger: logging.NewLogger(level),
levelFetchInterval: interval,
currentLevel: level,
}
if remoteConfigURL != "" {
go l.UpdateLogLevel()
}
return l
} Should it be l := &remoteLogger{
remoteURL: remoteConfigURL,
Logger: logging.NewLogger(level),
levelFetchInterval: interval,
currentLevel: level,
} ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Yes, we can to keep it uniform, but since we do not have methods defined to override the Logger interface(return type) we may not need to change the return to a pointer. Changing to a pointer does not seem to give us any benefit as when the interface is passed around since the underlying type is a large struct it is by design passed as a pointer. |
Beta Was this translation helpful? Give feedback.
Yes, we can to keep it uniform, but since we do not have methods defined to override the Logger interface(return type) we may not need to change the return to a pointer. Changing to a pointer does not seem to give us any benefit as when the interface is passed around since the underlying type is a large struct it is by design passed as a pointer.