Added yp2::PlainFile class which reads Unix-style plain text files.
[metaproxy-moved-to-github.git] / src / filter_log.cpp
index 2782dc5..34a335c 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.16 2006-01-17 15:08:02 adam Exp $
    Copyright (c) 2005, Index Data.
 
 %LICENSE%
@@ -6,7 +6,6 @@
 
 #include "config.hpp"
 
-#include "filter.hpp"
 #include "package.hpp"
 
 #include <string>
@@ -24,14 +23,12 @@ namespace yp2 {
     namespace filter {
         class Log::Rep {
             friend class Log;
-            static boost::mutex m_log_mutex;
+            boost::mutex m_log_mutex;
             std::string m_msg;
         };
     }
 }
 
-boost::mutex yf::Log::Rep::m_log_mutex;
-
 yf::Log::Log(const std::string &x) : m_p(new Rep)
 {
     m_p->m_msg = x;
@@ -53,7 +50,7 @@ void yf::Log::process(yp2::Package &package) const
 
     // scope for locking Ostream 
     { 
-        boost::mutex::scoped_lock scoped_lock(Rep::m_log_mutex);
+        boost::mutex::scoped_lock scoped_lock(m_p->m_log_mutex);
         std::cout << receive_time << " " << m_p->m_msg;
         std::cout << " request id=" << package.session().id();
         std::cout << " close=" 
@@ -78,7 +75,7 @@ void yf::Log::process(yp2::Package &package) const
 
     // scope for locking Ostream 
     { 
-        boost::mutex::scoped_lock scoped_lock(Rep::m_log_mutex);
+        boost::mutex::scoped_lock scoped_lock(m_p->m_log_mutex);
         std::cout << send_time << " " << m_p->m_msg;
         std::cout << " response id=" << package.session().id();
         std::cout << " close=" 
@@ -97,6 +94,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;