Browse Source

[master] Merged trac5267 (output_options vs config-get)

Francis Dupont 7 years ago
parent
commit
bcdcf25a21
1 changed files with 9 additions and 7 deletions
  1. 9 7
      src/lib/dhcpsrv/logging_info.cc

+ 9 - 7
src/lib/dhcpsrv/logging_info.cc

@@ -161,14 +161,16 @@ LoggingInfo::toElement() const {
     ElementPtr result = Element::createMap();
     // Set name
     result->set("name", Element::create(name_));
-    // Set output_options
-    ElementPtr options = Element::createList();
-    for (std::vector<LoggingDestination>::const_iterator dest =
-             destinations_.cbegin();
-         dest != destinations_.cend(); ++dest) {
-        options->add(dest->toElement());
+    // Set output_options if not empty
+    if (!destinations_.empty()) {
+        ElementPtr options = Element::createList();
+        for (std::vector<LoggingDestination>::const_iterator dest =
+                 destinations_.cbegin();
+             dest != destinations_.cend(); ++dest) {
+            options->add(dest->toElement());
+        }
+        result->set("output_options", options);
     }
-    result->set("output_options", options);
     // Set severity
     std::string severity;
     switch (severity_) {