Utils/Logger: Complete unit testing
[senf.git] / Utils / Logger / Target.cc
index e6fdc0c..c07ba21 100644 (file)
@@ -27,6 +27,7 @@
 //#include "Target.ih"
 
 // Custom includes
+#include <algorithm>
 
 //#include "Target.mpp"
 #define prefix_
@@ -66,6 +67,21 @@ prefix_ void senf::log::Target::route(std::string const & stream, std::string co
     route(s, a, level, action, index);
 }
 
+prefix_ void senf::log::Target::unroute(std::string const & stream, std::string const & area,
+                                        unsigned level, action_t action)
+{
+    detail::StreamBase const * s (StreamRegistry::instance().lookup(stream));
+    if (!s)
+        throw InvalidStreamException();
+    detail::AreaBase const * a (0);
+    if (! area.empty()) {
+        a = AreaRegistry::instance().lookup(area);
+        if (!a)
+            throw InvalidAreaException();
+    }
+    unroute(s, a, level, action);
+}
+
 prefix_ void senf::log::Target::unroute(int index)
 {
     RIB::iterator i;
@@ -104,7 +120,7 @@ prefix_ void senf::log::Target::route(detail::StreamBase const * stream,
             i = rib_.begin();
         else {
             i = rib_.end();
-            std::advance(i, -index - 1);
+            std::advance(i, index + 1 );
         }
     } else {
         if (RIB::size_type(index) >= rib_.size())