Extend log filter, so that message can be set
authorAdam Dickmeiss <adam@indexdata.dk>
Wed, 11 Jan 2006 08:53:52 +0000 (08:53 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Wed, 11 Jan 2006 08:53:52 +0000 (08:53 +0000)
etc/config1.xml
src/filter_log.cpp
src/filter_log.hpp

index d529e11..49d11a8 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0"?>
-<!-- $Id: config1.xml,v 1.7 2006-01-09 21:19:11 adam Exp $ -->
+<!-- $Id: config1.xml,v 1.8 2006-01-11 08:53:52 adam Exp $ -->
 <yp2 xmlns="http://indexdata.dk/yp2/config/1">
   <start route="start"/>
   <filters>
@@ -14,6 +14,9 @@
   <routes>  
     <route id="start">
       <filter refid="frontend"/>
+      <filter type="log">
+        <message>F</message>
+      </filter>
       <filter type="virt_db">
         <virtual>
           <database>loc</database>
           <database>idgils</database>
           <target>indexdata.dk/gils</target>
         </virtual>
+        <virtual>
+          <database>Default</database>
+          <target>localhost:9999</target>
+        </virtual>
+      </filter>
+      <filter type="log">
+        <message>B</message>
       </filter>
-      <filter type="log"/>
       <filter refid="backend"/>
     </route>
    </routes>
index 2782dc5..2f521d2 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: filter_log.cpp,v 1.13 2006-01-09 21:20:15 adam Exp $
+/* $Id: filter_log.cpp,v 1.14 2006-01-11 08:53:52 adam Exp $
    Copyright (c) 2005, Index Data.
 
 %LICENSE%
@@ -6,7 +6,7 @@
 
 #include "config.hpp"
 
-#include "filter.hpp"
+#include "xmlutil.hpp"
 #include "package.hpp"
 
 #include <string>
@@ -97,6 +97,23 @@ void yf::Log::process(yp2::Package &package) const
     }
 }
 
+void yf::Log::configure(const xmlNode *ptr)
+{
+    for (ptr = ptr->children; ptr; ptr = ptr->next)
+    {
+        if (ptr->type != XML_ELEMENT_NODE)
+            continue;
+        if (!strcmp((const char *) ptr->name, "message"))
+            m_p->m_msg = yp2::xml::get_text(ptr);
+        else
+        {
+            throw yp2::filter::FilterException("Bad element " 
+                                               + std::string((const char *)
+                                                             ptr->name));
+        }
+    }
+}
+
 static yp2::filter::Base* filter_creator()
 {
     return new yp2::filter::Log;
index 2ae395a..b6238b5 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: filter_log.hpp,v 1.12 2006-01-04 11:55:31 adam Exp $
+/* $Id: filter_log.hpp,v 1.13 2006-01-11 08:53:52 adam Exp $
    Copyright (c) 2005, Index Data.
 
 %LICENSE%
@@ -21,6 +21,7 @@ namespace yp2 {
             Log(const std::string &x);
             ~Log();
             void process(yp2::Package & package) const;
+            void configure(const xmlNode * ptr);
         };
     }
 }