Sam Jaffe 6 лет назад
Родитель
Сommit
75c0d4a529
1 измененных файлов с 8 добавлено и 6 удалено
  1. 8 6
      src/loggers/properties.cxx

+ 8 - 6
src/loggers/properties.cxx

@@ -57,20 +57,22 @@ namespace logging {
     })}
   })};
   
+  static properties mergeKey(std::string const & key,
+                             properties const & defVal,
+                             properties const & other) {
+    return other.contains(key) ? defVal.mergedWith(other[key]) : defVal;
+  }
+  
   properties properties::mergedWith(properties const & other) const {
     if (data.is<object_t>()) {
       properties out;
       for (auto & pair : object()) {
         auto & to = out.data.get<object_t>()[pair.first];
-        if (other.contains(pair.first)) {
-          to = pair.second.mergedWith(other[pair.first]);
-        } else {
-          to = pair.second;
-        }
+        to = mergeKey(pair.first, pair.second, other);
       }
       return out;
     } else {
-      return other;
+      return other.data.valid() ? other : *this;
     }
   }