[VOL-2991] Remove incorrect locks from backend.go
This commit consists of the following:
1) Remove the locks in the backend.go that were forcing all
ETCD requests to be serialized.
2) Minor change to the log to check whether a log level is
set before outputting message with serialized content.
Change-Id: I093eae006d9090fbeec75916ad82c329f1c61723
diff --git a/pkg/log/log.go b/pkg/log/log.go
index 6b7087f..9e0a0b5 100644
--- a/pkg/log/log.go
+++ b/pkg/log/log.go
@@ -552,7 +552,9 @@
// Debugw logs a message with some additional context. The variadic key-value
// pairs are treated as they are in With.
func (l logger) Debugw(msg string, keysAndValues Fields) {
- l.log.Debugw(msg, serializeMap(keysAndValues)...)
+ if l.V(DebugLevel) {
+ l.log.Debugw(msg, serializeMap(keysAndValues)...)
+ }
}
// Info logs a message at level Info on the standard logger.
@@ -575,7 +577,9 @@
// Infow logs a message with some additional context. The variadic key-value
// pairs are treated as they are in With.
func (l logger) Infow(msg string, keysAndValues Fields) {
- l.log.Infow(msg, serializeMap(keysAndValues)...)
+ if l.V(InfoLevel) {
+ l.log.Infow(msg, serializeMap(keysAndValues)...)
+ }
}
// Warn logs a message at level Warn on the standard logger.
@@ -596,7 +600,9 @@
// Warnw logs a message with some additional context. The variadic key-value
// pairs are treated as they are in With.
func (l logger) Warnw(msg string, keysAndValues Fields) {
- l.log.Warnw(msg, serializeMap(keysAndValues)...)
+ if l.V(WarnLevel) {
+ l.log.Warnw(msg, serializeMap(keysAndValues)...)
+ }
}
// Error logs a message at level Error on the standard logger.
@@ -617,7 +623,9 @@
// Errorw logs a message with some additional context. The variadic key-value
// pairs are treated as they are in With.
func (l logger) Errorw(msg string, keysAndValues Fields) {
- l.log.Errorw(msg, serializeMap(keysAndValues)...)
+ if l.V(ErrorLevel) {
+ l.log.Errorw(msg, serializeMap(keysAndValues)...)
+ }
}
// Fatal logs a message at level Fatal on the standard logger.
@@ -638,7 +646,9 @@
// Fatalw logs a message with some additional context. The variadic key-value
// pairs are treated as they are in With.
func (l logger) Fatalw(msg string, keysAndValues Fields) {
- l.log.Fatalw(msg, serializeMap(keysAndValues)...)
+ if l.V(FatalLevel) {
+ l.log.Fatalw(msg, serializeMap(keysAndValues)...)
+ }
}
// Warning logs a message at level Warn on the standard logger.