https://issues.shibboleth.net/jira/browse/CPPOST-57
authorScott Cantor <cantor.2@osu.edu>
Mon, 15 Nov 2010 22:04:36 +0000 (22:04 +0000)
committerScott Cantor <cantor.2@osu.edu>
Mon, 15 Nov 2010 22:04:36 +0000 (22:04 +0000)
saml/saml2/metadata/impl/XMLMetadataProvider.cpp

index 961cff6..57bb4cf 100644 (file)
 #include <xmltooling/util/Threads.h>
 #include <xmltooling/validation/ValidatorSuite.h>
 
+#if defined(OPENSAML_LOG4SHIB)
+# include <log4shib/NDC.hh>
+#elif defined(OPENSAML_LOG4CPP)
+# include <log4cpp/NDC.hh>
+#endif
+
 using namespace opensaml::saml2md;
 using namespace xmltooling::logging;
 using namespace xmltooling;
@@ -62,13 +68,25 @@ namespace opensaml {
 
             void init() {
                 try {
+                    if (!m_id.empty()) {
+                        string threadid("[");
+                        threadid += m_id + ']';
+                        logging::NDC::push(threadid);
+                    }
                     background_load();
                     startup();
                 }
                 catch (...) {
                     startup();
+                    if (!m_id.empty()) {
+                        logging::NDC::pop();
+                    }
                     throw;
                 }
+
+                if (!m_id.empty()) {
+                    logging::NDC::pop();
+                }
             }
 
             const XMLObject* getMetadata() const {