getenv for logging removed
authorStefan Schubert <schubi@suse.de>
Wed, 4 Jan 2006 12:28:50 +0000 (12:28 +0000)
committerStefan Schubert <schubi@suse.de>
Wed, 4 Jan 2006 12:28:50 +0000 (12:28 +0000)
13 files changed:
zypp/solver/detail/QueueItemRequire.cc
zypp/solver/detail/QueueItemUninstall.cc
zypp/solver/detail/ResItemAndDependency.cc
zypp/solver/detail/Resolver.cc
zypp/solver/detail/ResolverContext.cc
zypp/solver/detail/ResolverQueue.cc
zypp/solver/detail/StoreWorld.cc
zypp/solver/detail/UndumpWorld.cc
zypp/solver/detail/World.cc
zypp/solver/detail/XmlNode.cc
zypp/solver/detail/XmlNode.h
zypp/solver/detail/XmlParser.cc
zypp/solver/detail/extract.cc

index a4c59c3..a62e52a 100644 (file)
@@ -30,6 +30,7 @@
 #include <zypp/solver/detail/ResolverInfoNeededBy.h>
 #include <zypp/solver/detail/World.h>
 #include <zypp/CapSet.h>
+#include <zypp/base/Logger.h>
 
 /////////////////////////////////////////////////////////////////////////
 namespace zypp
@@ -233,10 +234,10 @@ namespace zypp
       bool
       QueueItemRequire::process (ResolverContext_Ptr context, QueueItemList & new_items)
       {
-          if (getenv ("RC_SPEW")) fprintf (stderr, "QueueItemRequire::process(%s)\n", this->asString().c_str());
+          _DBG("RC_SPEW") << "QueueItemRequire::process(" << this->asString() << ")" << endl;
 
           if (context->requirementIsMet (_dep, _is_child)) {
-       if (getenv ("RC_SPEW")) fprintf (stderr, "requirement is already met in current context\n");
+             _DBG("RC_SPEW") <<  "requirement is already met in current context" << endl;
       //    rc_queue_item_free (item);
        return true;
           }
@@ -257,14 +258,14 @@ namespace zypp
 
        num_providers = info.providers.size();
 
-       if (getenv ("RC_SPEW")) fprintf (stderr, "requirement is met by %d resolvable\n", num_providers);
+       _DBG("RC_SPEW") << "requirement is met by " << num_providers << " resolvable";
           }
 
           std::string msg;
 
           if (num_providers == 0) {
 
-       if (getenv ("RC_SPEW")) fprintf (stderr, "Unfulfilled requirement, try different solution\n");
+             _DBG("RC_SPEW") << "Unfulfilled requirement, try different solution" << endl;
 
        QueueItemUninstall_Ptr uninstall_item = NULL;
        QueueItemBranch_Ptr branch_item = NULL;
@@ -410,7 +411,7 @@ namespace zypp
 
           } else if (num_providers == 1) {
 
-       if (getenv ("RC_SPEW")) fprintf (stderr, "Found exactly one resolvable, installing it.\n");
+             _DBG("RC_SPEW") << "Found exactly one resolvable, installing it." << endl;
 
        QueueItemInstall_Ptr install_item = new QueueItemInstall (world(), info.providers.front());
        install_item->addDependency (_dep);
@@ -423,7 +424,7 @@ namespace zypp
 
           } else if (num_providers > 1) {
 
-       if (getenv ("RC_SPEW")) fprintf (stderr, "Found more than one resolvable, branching.\n");
+             _DBG("RC_SPEW") << "Found more than one resolvable, branching." << endl;
 
       //fprintf (stderr, "Found more than one resItem, branching.\n");
        QueueItemBranch_Ptr branch_item = new QueueItemBranch (world());
index d9637c0..3d6fc42 100644 (file)
@@ -26,6 +26,7 @@
 #include <zypp/solver/detail/ResolverInfoMissingReq.h>
 #include <zypp/solver/detail/World.h>
 #include <zypp/CapSet.h>
+#include <zypp/base/Logger.h>
 
 /////////////////////////////////////////////////////////////////////////
 namespace zypp
@@ -197,7 +198,10 @@ namespace zypp
 
           status = context->getStatus (_resItem);
 
-          if (getenv ("RC_SPEW")) fprintf (stderr, "QueueItemUninstall::process(<%s>%s)%s\n", ResolverContext::toString(status).c_str(), _resItem->asString().c_str(), _unlink ? "[unlink]" : "");
+          _DBG("RC_SPEW") << "QueueItemUninstall::process(<" << ResolverContext::toString(status) << ">" << _resItem->asString() << ")";
+         if (_unlink)
+             _DBG("RC_SPEW") << "[unlink]";
+         _DBG("RC_SPEW") << endl;
 
           /* In the case of an unlink, we only want to uninstall the resItem if it is
              being used by something else.  We can't really determine this with 100%
index 14bed93..12e897d 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <zypp/solver/detail/ResItemAndDependency.h>
 #include <zypp/solver/detail/debug.h>
+#include <zypp/base/Logger.h>
 
 /////////////////////////////////////////////////////////////////////////
 namespace zypp
@@ -97,7 +98,7 @@ namespace zypp
           //if (!dep.matches (_dependency)) {
        return false;
           //}
-          if (getenv ("SPEW_DEP")) fprintf (stderr, "ResItemAndDependency::verifyRelation _resItem->channel() %s, dep->channel() %s\n", _resItem->channel()->asString().c_str(), dep->channel()->asString().c_str());
+          _DBG("SPEW_DEP") << "ResItemAndDependency::verifyRelation _resItem->channel() " << _resItem->channel()->asString() << ", dep->channel()" << dep->channel()->asString() << endl;
           return _resItem->channel()->equals (dep->channel());
       #endif
 #else
index c23734e..fe80281 100644 (file)
@@ -26,6 +26,7 @@
 #include <zypp/solver/detail/World.h>
 #include <zypp/solver/detail/StoreWorld.h>
 #include <zypp/solver/detail/MultiWorld.h>
+#include <zypp/base/Logger.h>
 
 /////////////////////////////////////////////////////////////////////////
 namespace zypp
@@ -172,7 +173,7 @@ namespace zypp
       void
       Resolver::verifySystem (void)
       {
-          if (getenv ("RC_SPEW")) fprintf (stderr, "Resolver::verifySystem()\n");
+          _XXX("RC_SPEW") <<  "Resolver::verifySystem()" << endl;
           world()->foreachResItem (new Channel(CHANNEL_TYPE_SYSTEM), verify_system_cb, this);
 
           _verifying = true;
@@ -238,10 +239,9 @@ namespace zypp
       {
 
           time_t t_start, t_now;
-          bool extremely_noisy = getenv ("RC_SPEW") != NULL;
           bool have_local_resItems = false;
 
-          if (extremely_noisy) fprintf (stderr, "Resolver::resolveDependencies()\n");
+          _XXX("RC_SPEW") << "Resolver::resolveDependencies()" << endl;
 
           /* Walk through are list of to-be-installed packages and see if any of them are local. */
 
@@ -323,7 +323,7 @@ namespace zypp
        initial_queue->addExtraConflict (*iter);
           }
 
-          if (extremely_noisy) fprintf (stderr, "Initial Queue: [%s]\n", initial_queue->asString().c_str());
+          _XXX("RC_SPEW") << "Initial Queue: [" << initial_queue->asString() << "]" << endl;
 
           _pending_queues.push_front (initial_queue);
 
@@ -331,30 +331,32 @@ namespace zypp
 
           while (!_pending_queues.empty()) {
 
-       if (extremely_noisy) {
-           printf ("Pend %ld / Cmpl %ld / Prun %ld / Defr %ld / Invl %ld\n\n", (long) _pending_queues.size(), (long) _complete_queues.size(), (long) _pruned_queues.size(), (long) _deferred_queues.size(), (long) _invalid_queues.size());
-       }
+             _XXX("RC_SPEW") << "Pend " << (long) _pending_queues.size()
+                             << " / Cmpl " << (long) _complete_queues.size()
+                             << " / Prun " << (long) _pruned_queues.size()
+                             << " / Defr " << (long) _deferred_queues.size()
+                             << " / Invl " << (long) _invalid_queues.size() << endl;
 
-       if (_timeout_seconds > 0) {
-           time (&t_now);
-           if (difftime (t_now, t_start) > _timeout_seconds) {
-               _timed_out = true;
-               break;
-           }
-       }
+             if (_timeout_seconds > 0) {
+                 time (&t_now);
+                 if (difftime (t_now, t_start) > _timeout_seconds) {
+                     _timed_out = true;
+                     break;
+                 }
+             }
 
-       ResolverQueue_Ptr queue = _pending_queues.front();
-       _pending_queues.pop_front();
-       ResolverContext_Ptr context = queue->context();
+             ResolverQueue_Ptr queue = _pending_queues.front();
+             _pending_queues.pop_front();
+             ResolverContext_Ptr context = queue->context();
 
-       queue->process();
+             queue->process();
 
-       if (queue->isInvalid ()) {
-           if (extremely_noisy) printf ("Invalid Queue\n");
-           _invalid_queues.push_front (queue);
+             if (queue->isInvalid ()) {
+                 _XXX("RC_SPEW") << "Invalid Queue\n" << endl;;
+             _invalid_queues.push_front (queue);
 
-       } else if (queue->isEmpty ()) {
-           if (extremely_noisy) printf ("Empty Queue\n");
+         } else if (queue->isEmpty ()) {
+             _XXX("RC_SPEW") <<"Empty Queue\n" << endl;
 
            _complete_queues.push_front (queue);
 
@@ -376,7 +378,7 @@ namespace zypp
            /* If we aren't currently as good as our previous best complete solution,
               this solution gets pruned. */
 
-           if (extremely_noisy) printf ("PRUNED!\n");
+           _XXX("RC_SPEW") << "PRUNED!" << endl;
 
            _pruned_queues.push_front(queue);
 
@@ -397,12 +399,12 @@ namespace zypp
            && !_deferred_queues.empty()) {
            _pending_queues.push_front (_deferred_queues.front());
        }
-          }
-
-          if (extremely_noisy) {
-       printf ("Pend %ld / Cmpl %ld / Prun %ld / Defr %ld / Invl %ld\n--------\n", (long) _pending_queues.size(), (long) _complete_queues.size(), (long) _pruned_queues.size(), (long) _deferred_queues.size(), (long) _invalid_queues.size());
-          }
-
+         }
+       _XXX("RC_SPEW") << "Pend " << (long) _pending_queues.size()
+                       << " / Cmpl " << (long) _complete_queues.size()
+                       << " / Prun " << (long) _pruned_queues.size()
+                       << " / Defr " << (long) _deferred_queues.size()
+                       << " / Invl " << (long) _invalid_queues.size() << endl;
           return;
       }
 
index 0145048..3272dab 100644 (file)
 
 #include <values.h>
 
-#include <zypp/base/String.h>
-#include <zypp/solver/detail/ResolverContext.h>
-#include <zypp/solver/detail/ResolverInfoMisc.h>
-#include <zypp/solver/detail/MultiWorld.h>
-#include <zypp/solver/detail/World.h>
-#include <zypp/CapSet.h>
+#include "zypp/base/String.h"
+#include "zypp/solver/detail/ResolverContext.h"
+#include "zypp/solver/detail/ResolverInfoMisc.h"
+#include "zypp/solver/detail/MultiWorld.h"
+#include "zypp/solver/detail/World.h"
+#include "zypp/CapSet.h"
+#include "zypp/base/Logger.h"
 
 /////////////////////////////////////////////////////////////////////////
 namespace zypp
@@ -226,7 +227,8 @@ ResolverContext::installResItem (ResItem_constPtr resItem, bool is_soft, int oth
     std::string msg;
 
     status = getStatus (resItem);
-    if (getenv ("RC_SPEW")) fprintf (stderr, "ResolverContext[%p]::installResItem(<%s>%s)\n", this, ResolverContext::toString(status).c_str(), resItem->asString().c_str());
+    _DBG("RC_SPEW") << "ResolverContext[" << this << "]::installResItem(<" << ResolverContext::toString(status)
+                   << "> " << resItem->asString() << ")" << endl;
 
     if (resItem_status_is_to_be_uninstalled (status)
        && status != RESOLVABLE_STATUS_TO_BE_UNINSTALLED_DUE_TO_UNLINK) {
@@ -283,7 +285,8 @@ ResolverContext::upgradeResItem (ResItem_constPtr resItem, ResItem_constPtr old_
     ResItemStatus status;
     int priority;
 
-    if (getenv ("RC_SPEW")) fprintf (stderr, "ResolverContext[%p]::upgradeResItem(%s upgrades %s)\n", this, resItem->asString().c_str(), old_resItem->asString().c_str());
+    _DBG("RC_SPEW") << "ResolverContext[" << this << "]::upgradeResItem(" << resItem->asString() << " upgrades "
+                   << old_resItem->asString() << ")" << endl;
 
     status = getStatus (resItem);
 
@@ -325,7 +328,10 @@ ResolverContext::uninstallResItem (ResItem_constPtr resItem, bool part_of_upgrad
     ResItemStatus status, new_status;
     std::string msg;
 
-    if (getenv ("RC_SPEW")) fprintf (stderr, "ResolverContext[%p]::uninstallResItem(%s %s %s %s)\n", this, resItem->asString().c_str(), part_of_upgrade ? "part_of_upgrade" : "", due_to_obsolete ? "due_to_obsolete": "", due_to_unlink ? "due_to_unlink" : "");
+    _DBG("RC_SPEW") << "ResolverContext[" << this << "]::uninstallResItem("
+                   << resItem->asString() << " " << (part_of_upgrade ? "part_of_upgrade" : "") << " "
+                   << (due_to_obsolete ? "due_to_obsolete": "") << " "
+                   << (due_to_unlink ? "due_to_unlink" : "") << ")" << endl;
 
     assert (! (due_to_obsolete && due_to_unlink));
 
@@ -667,7 +673,7 @@ ResolverContext::upgradeCount (void)
 void
 ResolverContext::addInfo (ResolverInfo_Ptr info)
 {
-    if (getenv ("RC_SPEW")) fprintf (stderr, "ResolverContext[%p]::addInfo(%s)\n", this, info->asString().c_str());
+    _DBG("RC_SPEW") << "ResolverContext[" << this << "]::addInfo(" << info->asString() << ")" << endl;
     _log.push_back (info);
 
     // _propagated_importance = false;
@@ -688,7 +694,7 @@ ResolverContext::addInfo (ResolverInfo_Ptr info)
 void
 ResolverContext::addInfoString (ResItem_constPtr resItem, int priority, string msg)
 {
-//    if (getenv ("RC_SPEW")) fprintf (stderr, "ResolverContext::addInfoString(%s) %s\n", resItem ? resItem->asString().c_str() : "", msg.c_str());
+    _XXX("RC_SPEW") << "ResolverContext::addInfoString(" << (resItem ? resItem->asString().c_str() : "") << ") " << msg << endl;
     ResolverInfo_Ptr info = new ResolverInfoMisc (resItem, priority, msg);
     addInfo (info);
 }
@@ -934,7 +940,7 @@ spew_info_cb (ResolverInfo_Ptr info, void *unused)
 void
 ResolverContext::spewInfo (void)
 {
-    if (getenv ("RC_SPEW")) fprintf (stderr, "ResolverContext[%p]::spewInfo()\n", this);
+    _DBG("RC_SPEW") << "ResolverContext[" << this << "]::spewInfo" << endl;
     foreachInfo (NULL, -1, spew_info_cb, NULL);
 }
 
index 24a6de2..d39249f 100644 (file)
@@ -31,6 +31,7 @@
 #include <zypp/solver/detail/QueueItemUninstall.h>
 #include <zypp/solver/detail/ResolverContext.h>
 #include <zypp/CapSet.h>
+#include <zypp/base/Logger.h>
 
 /////////////////////////////////////////////////////////////////////////
 namespace zypp
@@ -223,16 +224,16 @@ namespace zypp
           int max_priority;
           bool did_something = false;
 
-          if (getenv ("QUEUE_SPEW")) fprintf (stderr, "ResolverQueue::processOnce(%s), %d items\n", asString().c_str(), (int) _items.size());
+          _DBG("QUEUE_SPEW") << "ResolverQueue::processOnce(" << asString() <<", " << (int) _items.size() << " items" << endl;
           while ( (max_priority = itemlist_max_priority (_items)) >= 0
            && _context->isValid () ) {
 
        bool did_something_recently = false;
 
-          if (getenv ("QUEUE_SPEW")) fprintf (stderr, "ResolverQueue::processOnce() inside loop\n");
+       _DBG("QUEUE_SPEW") << "ResolverQueue::processOnce() inside loop" << endl;
        for (QueueItemList::iterator iter = _items.begin(); iter != _items.end() && _context->isValid();) {
            QueueItem_Ptr item = *iter;
-           if (getenv ("QUEUE_SPEW")) fprintf (stderr, "=====> 1st pass: [%s]\n", item->asString().c_str());
+           _DBG("QUEUE_SPEW") <<  "=====> 1st pass: [" << item->asString() << "]" << endl;
            QueueItemList::iterator next = iter; next++;
            if (item && item->priority() == max_priority) {
                if (item->process (_context, new_items)) {
@@ -249,7 +250,7 @@ namespace zypp
           }
 
           _items = new_items;
-          if (getenv ("QUEUE_SPEW")) fprintf (stderr, "%d items after first pass\n", (int) _items.size());
+          _DBG("QUEUE_SPEW") <<  (int) _items.size() << " items after first pass" << endl;
 
           /*
              Now make a second pass over the queue, removing any super-branches.
@@ -257,20 +258,20 @@ namespace zypp
              the larger branch can be dropped.
           */
 
-      //    if (getenv ("QUEUE_SPEW")) fprintf (stderr, "ResolverQueue::processOnce() second pass\n");
+          _XXX("QUEUE_SPEW") <<  "ResolverQueue::processOnce() second pass" << endl;
           for (QueueItemList::iterator iter = _items.begin(); iter != _items.end();) {
        QueueItemList::iterator next = iter; next++;
        QueueItem_Ptr item = *iter;
 
-       if (getenv ("QUEUE_SPEW")) fprintf (stderr, "=====> 2nd pass: [%s]\n", item->asString().c_str());
+       _DBG("QUEUE_SPEW") <<  "=====> 2nd pass: [" << item->asString() << "]" << endl;
        if (item->isBranch()) {
-           if (getenv ("QUEUE_SPEW")) fprintf (stderr, "ResolverQueue::processOnce() is branch\n");
+           _DBG("QUEUE_SPEW") << "ResolverQueue::processOnce() is branch" << endl;
            QueueItemBranch_Ptr branch = dynamic_pointer_cast<QueueItemBranch>(item);
            for (QueueItemList::const_iterator iter2 = _items.begin(); iter2 != _items.end(); iter2++) {
-               if (getenv ("QUEUE_SPEW")) fprintf (stderr, "Compare branch with [%s]\n", (*iter2)->asString().c_str());
+               _DBG("QUEUE_SPEW") << "Compare branch with [" << (*iter2)->asString() << "]" << endl;
                if (iter != iter2
                    && branch->contains (*iter2)) {
-                   if (getenv ("QUEUE_SPEW")) fprintf (stderr, "Contained within, removing\n");
+                   _DBG("QUEUE_SPEW") << "Contained within, removing" << endl;
                    _items.erase (iter);
                    break;
                }
@@ -278,7 +279,10 @@ namespace zypp
        }
        iter = next;
           }
-          if (getenv ("QUEUE_SPEW")) fprintf (stderr, "did %sthing: %d items\n", did_something ? "some" : "no", (int)_items.size());
+         if (did_something)
+             _DBG("QUEUE_SPEW") <<  "did somesthing: " << (int)_items.size() << " items" << endl;
+         else
+             _DBG("QUEUE_SPEW") <<  "did nothing: " << (int)_items.size() << " items" << endl;       
 
           return did_something;
       }
@@ -287,22 +291,14 @@ namespace zypp
       void
       ResolverQueue::process ()
       {
-          bool very_noisy;
-
-          very_noisy = getenv ("RC_SPEW") != NULL;
-
-          if (very_noisy) {
-       printf ("----- Processing -----\n");
-       spew ();
-          }
+         _DBG("RC_SPEW") << "----- Processing -----" << endl;
+         spew ();
 
           while (_context->isValid ()
-          && ! isEmpty ()
-          && processOnce ()) {
-       /* all of the work is in the conditional! */
-       if (very_noisy) {
-           spew ();
-       }
+                && ! isEmpty ()
+                && processOnce ()) {
+             /* all of the work is in the conditional! */
+             spew ();
           }
       }
 
@@ -427,21 +423,20 @@ namespace zypp
       void
       ResolverQueue::spew ()
       {
-          printf ("Resolver Queue: %s\n", _context->isInvalid() ? "INVALID" : "");
+          _DBG("RC_SPEW") << "Resolver Queue: " << (_context->isInvalid() ? "INVALID" : "") << endl;
 
           if (_items.empty()) {
 
-       printf ("  (empty)\n");
+             _DBG("RC_SPEW") <<  "  (empty)" << endl;
 
           } else {
-
-       for (QueueItemList::const_iterator iter = _items.begin(); iter != _items.end(); iter++) {
-           printf ("  %s\n", (*iter)->asString().c_str());
-       }
+             for (QueueItemList::const_iterator iter = _items.begin(); iter != _items.end(); iter++) {
+                 _DBG("RC_SPEW") << "  " << (*iter)->asString() << endl;
+             }
 
           }
 
-          printf ("\n");
+          _DBG("RC_SPEW") << endl;
           fflush (stdout);
       }
 
index cef5cda..5e03cf5 100644 (file)
@@ -27,6 +27,7 @@
 #include <zypp/solver/detail/debug.h>
 #include <zypp/Arch.h>
 #include <zypp/CapSet.h>
+#include <zypp/base/Logger.h>
 
 /////////////////////////////////////////////////////////////////////////
 namespace zypp
@@ -270,7 +271,8 @@ namespace zypp
       void
       StoreWorld::removeResItem (ResItem_constPtr resItem)
       {
-          if (getenv("RC_SPEW")) fprintf (stderr, "StoreWorld::removeResItem (%s)\n", resItem->asString().c_str());
+          _DBG("RC_SPEW") << "StoreWorld::removeResItem ("
+                         << resItem->asString() << ")" << endl;
 
           Channel_constPtr channel = resItem->channel ();
 
@@ -581,8 +583,7 @@ namespace zypp
 
        if (r_and_d)
       //fprintf (stderr, "==> %s verify %s ? %s\n", r_and_d->asString().c_str(), dep->asString().c_str(), r_and_d->verifyRelation (dep) ? "Y" : "N");
-       if (r_and_d {//&& r_and_d->dependency().matches (dep)) {
-
+       if (r_and_d) {//&& r_and_d->dependency().matches (dep)) {
            /* Skip dups if one of them in installed. */
            if (r_and_d->resItem()->isInstalled()
                || installed.find(r_and_d->resItem()) == installed.end()) {
index 179e832..bf069a7 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <zypp/solver/detail/UndumpWorld.h>
 #include <zypp/solver/detail/extract.h>
+#include <zypp/base/Logger.h>
 
 /////////////////////////////////////////////////////////////////////////
 namespace zypp 
@@ -132,7 +133,8 @@ namespace zypp
       void
       UndumpWorld::setSubscription (Channel_constPtr channel, bool subscribe)
       {
-      //    if (getenv("RC_SPEW")) fprintf (stderr, "UndumpWorld::setSubscription (%s, %s)\n", channel->asString().c_str(), subscribe?"subscribe":"unsubscribe");
+         _XXX("RC_SPEW") << "UndumpWorld::setSubscription (" << channel->asString() << " , " <<  (subscribe?"subscribe":"unsubscribe")
+                         << ")" << endl;
           for (ChannelSubscriptions::iterator i = _subscriptions.begin(); i != _subscriptions.end(); i++) {
        if (*i == channel) {
            if (!subscribe) {
@@ -155,12 +157,12 @@ namespace zypp
       {
           for (ChannelSubscriptions::const_iterator i = _subscriptions.begin(); i != _subscriptions.end(); i++) {
        if (*i == channel) {
-           if (getenv("RC_SPEW")) fprintf (stderr, "UndumpWorld::isSubscribed (%s) YES\n", channel->asString().c_str());
+           _DBG("RC_SPEW") << "UndumpWorld::isSubscribed (" << channel->asString() <<") YES" << endl;
            return true;
        }
           }
       
-          if (getenv("RC_SPEW")) fprintf (stderr, "UndumpWorld::isSubscribed (%s) NO\n", channel->asString().c_str());
+          _DBG("RC_SPEW") << "UndumpWorld::isSubscribed (" << channel->asString() << ") NO" << endl;
           return false;
       }
       
index 9e2ffe3..85df91f 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <zypp/solver/detail/MultiWorld.h>
 #include <zypp/solver/detail/Subscription.h>
+#include "zypp/base/Logger.h"
 
 /////////////////////////////////////////////////////////////////////////
 namespace zypp
@@ -178,7 +179,8 @@ namespace zypp
 
           if (channel == NULL) return;
 
-      //    if (getenv("RC_SPEW")) fprintf (stderr, "World::setSubscription (%s, %s)\n", channel->asString().c_str(), is_subscribed?"subscribe":"unsubscribe");
+         _XXX("RC_SPEW") << "World::setSubscription (" << channel->asString() << ", " <<
+             (is_subscribed?"subscribe":"unsubscribe") << ")" << endl;
 
           if (channel->system ()) {
        fprintf (stderr, "Can't subscribe to system channel '%s'\n",  channel->name ());
@@ -200,7 +202,7 @@ namespace zypp
       World::isSubscribed (Channel_constPtr channel) const
       {
           if (channel == NULL) return false;
-      //    if (getenv("RC_SPEW")) fprintf (stderr, "World::isSubscribed (%s)\n", channel->asString().c_str());
+         _XXX("RC_SPEW") <<  "World::isSubscribed (" << channel->asString() << ")" << endl;
 
           if (channel->system ())
        return false;
index 5d1238e..f4b0310 100644 (file)
@@ -24,6 +24,7 @@
  */
 
 #include <zypp/solver/detail/XmlNode.h>
+#include <zypp/base/Logger.h>
 
 /////////////////////////////////////////////////////////////////////////
 namespace zypp 
@@ -95,7 +96,7 @@ namespace zypp
           xmlNode *child;
       
           xml_s = xmlGetProp(_node, (const xmlChar *)name);
-      //    if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlNode::getValue(%s) xmlGetProp '%s'\n", name, (char *)xml_s);
+         _XXX("RC_SPEW_XML") << "XmlNode::getValue(" << name << ") xmlGetProp '" << (char *)xml_s << "'" << endl;
       
           if (xml_s) {
        ret = strdup ((const char *)xml_s);
@@ -106,10 +107,12 @@ namespace zypp
           child = _node->xmlChildrenNode;
       
           while (child) {
-      //       if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlNode::getValue(%s) child '%s'\n", name, (const char *)(child->name));
+             _XXX("RC_SPEW_XML") << "XmlNode::getValue(" << name << ") child '" << (const char *)(child->name) << "'" 
+                                 << endl;
        if (strcasecmp((const char *)(child->name), name) == 0) {
            xml_s = xmlNodeGetContent(child);
-      //           if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlNode::getValue(%s) xmlNodeGetContent '%s'\n", name, (char *)xml_s);
+           _XXX("RC_SPEW_XML") << "XmlNode::getValue(" << name << ") xmlNodeGetContent '" << (char *)xml_s << "'"
+                               << endl;
            if (xml_s) {
                ret = strdup ((const char *)xml_s);
                xmlFree (xml_s);
@@ -119,7 +122,7 @@ namespace zypp
        child = child->next;
           }
       
-      //    if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlNode::getValue(%s) NULL\n", name);
+         _XXX("RC_SPEW_XML") << "XmlNode::getValue(" << name << ") NULL" << endl;
           return deflt;
       }
       
@@ -131,7 +134,8 @@ namespace zypp
           char *gs;
       
           ret = xmlGetProp (_node, (const xmlChar *)name);
-      //    if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlNode::getProp(%s) xmlGetProp '%s'\n", name, (char *)ret);
+         _XXX("RC_SPEW_XML") << "XmlNode::getProp(" << name << ") xmlGetProp '" << (char *)ret << "'"
+                             << endl;
           if (ret) {
        gs = strdup ((const char *)ret);
        xmlFree (ret);
index 5eeb94e..43cf222 100644 (file)
@@ -23,7 +23,7 @@
 #define _XmlNode_h
 
 #include <list>
-
+#include <iostream>
 #include <iosfwd>
 #include <string>
 #include <libxml/parser.h>
index 13d93ee..b9d4773 100644 (file)
 #include <config.h>
 #include <ctype.h>
 #include <assert.h>
-#include <zypp/solver/detail/XmlParser.h>
-#include <zypp/solver/detail/PackageUpdate.h>
-#include <zypp/solver/detail/utils.h>
-
-#include <zypp/solver/detail/debug.h>
-#include <zypp/ResObject.h>
-
-#include <zypp/CapFactory.h>
-#include <zypp/CapSet.h>
-#include <zypp/Dependencies.h>
+#include "zypp/solver/detail/XmlParser.h"
+#include "zypp/solver/detail/PackageUpdate.h"
+#include "zypp/solver/detail/utils.h"
+#include "zypp/solver/detail/debug.h"
+#include "zypp/ResObject.h"
+#include "zypp/CapFactory.h"
+#include "zypp/CapSet.h"
+#include "zypp/Dependencies.h"
+#include "zypp/base/Logger.h"
 
 /////////////////////////////////////////////////////////////////////////
 namespace zypp 
@@ -75,7 +74,7 @@ namespace zypp
                     else if (!strcasecmp(attr, "arch"))            arch = value;
                     else if (!strcasecmp (attr, "obsoletes"))   *is_obsolete = true;
                     else {
-                        if (getenv ("RC_SPEW_XML"))    rc_debug (RC_DEBUG_LEVEL_ALWAYS, "! Unknown attribute: %s = %s", attr, value);
+                        _DBG("RC_SPEW_XML") << "! Unknown attribute: " << attr << " = " << value << endl;
                     }
       
                 }
@@ -98,7 +97,7 @@ namespace zypp
                 XmlParser *ctx = (XmlParser *)ptr;
                 if (ctx->processing()) return;
       
-                //    if (getenv ("RC_SPEW_XML")) rc_debug (RC_DEBUG_LEVEL_ALWAYS, "* Start document");
+                _XXX("RC_SPEW_XML") << "* Start document" << endl;
       
                 ctx->setProcessing (true);
             }
@@ -110,7 +109,7 @@ namespace zypp
                 XmlParser *ctx = (XmlParser *)ptr;
                 if (!ctx->processing()) return;
       
-                //    if (getenv ("RC_SPEW_XML")) rc_debug (RC_DEBUG_LEVEL_ALWAYS, "* End document");
+                _XXX("RC_SPEW_XML") << "* End document" << endl;
       
                 ctx->setProcessing (false);
             }
@@ -124,11 +123,11 @@ namespace zypp
                 ctx->releaseBuffer();
       
 #if 0
-                //    if (getenv ("RC_SPEW_XML"))      rc_debug (RC_DEBUG_LEVEL_ALWAYS, "* Start element (%s)", (const char *)name);
+                _XXX("RC_SPEW_XML") <<  "* Start element (" << (const char *)name << ")";
       
                 if (attrs) {
                     for (int i = 0; attrs[i]; i += 2) {
-                        if (getenv ("RC_SPEW_XML")) rc_debug (RC_DEBUG_LEVEL_ALWAYS, "   - Attribute (%s=%s)", (const char *)attrs[i], (const char *)attrs[i+1]);
+                        _DBG("RC_SPEW_XML") <<  "   - Attribute (" << (const char *)attrs[i] << "=" << (const char *)attrs[i+1] << ")" << endl;
                     }
                 }
 #endif
@@ -147,7 +146,7 @@ namespace zypp
             {
                 XmlParser *ctx = (XmlParser *)ptr;
       
-                //    if (getenv ("RC_SPEW_XML"))      rc_debug (RC_DEBUG_LEVEL_ALWAYS, "* End element (%s)", (const char *)name);
+                _XXX("RC_SPEW_XML") << "* End element (" << (const char *)name << ")" << endl;
           
                 if (!strcmp((const char *)name, "channel") || !strcmp((const char *)name, "subchannel")) {
                     /* Unneeded container tags.  Ignore */
@@ -239,7 +238,7 @@ namespace zypp
                 , _text_buffer (NULL)
                 , _text_buffer_size (0)
             {
-                //    if (getenv ("RC_SPEW_XML")) rc_debug (RC_DEBUG_LEVEL_ALWAYS, "* Context created (%p)", this);
+                _XXX("RC_SPEW_XML") <<  "* Context created (" << this << ")" << endl;
             }
       
       
@@ -288,7 +287,7 @@ namespace zypp
                 _text_buffer_size += size;
                 _text_buffer[_text_buffer_size] = 0;
       
-                //    if (getenv ("RC_SPEW_XML"))      fprintf (stderr, "XmlParser[%p]::toBuffer(%.32s...,%ld)\n", this, data, (long)size);
+                _XXX("RC_SPEW_XML") << "XmlParser[" << this << "]::toBuffer(" << data << "...," << (long)size << ")" << endl;
             }
       
       
@@ -299,14 +298,14 @@ namespace zypp
                     free (_text_buffer);
                 _text_buffer = NULL;
                 _text_buffer_size = 0;
-                //    if (getenv ("RC_SPEW_XML"))      fprintf (stderr, "XmlParser[%p]::releaseBuffer()\n", this);
+                _XXX("RC_SPEW_XML") <<  "XmlParser[" << this << "]::releaseBuffer()" << endl;
             }
       
       
             void
             XmlParser::parseChunk(const char *xmlbuf, size_t size)
             {
-                if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::parseChunk(%.32s...,%ld)\n", xmlbuf, (long)size);
+                _DBG("RC_SPEW_XML") << "XmlParser::parseChunk(" << xmlbuf << "...," << (long)size << ")" << endl;
       
                 xmlSubstituteEntitiesDefault(true);
           
@@ -321,7 +320,7 @@ namespace zypp
             PackageList
             XmlParser::done()
             {
-                //    if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::done()\n");
+                _XXX("RC_SPEW_XML") << "XmlParser::done()" << endl;
       
                 if (_processing)
                     xmlParseChunk(_xml_context, NULL, 0, 1);
@@ -347,7 +346,7 @@ namespace zypp
             void
             XmlParser::startElement(const char *name, const xmlChar **attrs)
             {
-                //    if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::startElement(%s)\n", name);
+                _XXX("RC_SPEW_XML") << "XmlParser::startElement(" << name << ")" << endl;
       
                 switch (_state) {
                     case PARSER_TOPLEVEL:
@@ -373,7 +372,7 @@ namespace zypp
             void
             XmlParser::endElement(const char *name)
             {
-                //    if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::endElement(%s)\n", name);
+                _XXX("RC_SPEW_XML") <<  "XmlParser::endElement(" << name << ")" << endl;
       
                 if (name != NULL) {                    // sax_end_element might set name to NULL
                     switch (_state) {
@@ -403,7 +402,7 @@ namespace zypp
             void
             XmlParser::toplevelStart(const char * name, const xmlChar **attrs)
             {
-                //    if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::toplevelStart(%s)\n", name);
+                _XXX("RC_SPEW_XML") << "XmlParser::toplevelStart(" << name << ")" << endl;
       
                 if (!strcmp(name, "package")) {
             
@@ -434,7 +433,7 @@ namespace zypp
       
                 }
                 else {
-                    if (getenv ("RC_SPEW_XML")) rc_debug (RC_DEBUG_LEVEL_ALWAYS, "! Not handling %s at toplevel", (const char *)name);
+                    _DBG("RC_SPEW_XML") << "! Not handling " << (const char *)name << " at toplevel" << endl;
                 }
             }
       
@@ -442,7 +441,7 @@ namespace zypp
             void
             XmlParser::packageStart(const char * name, const xmlChar **attrs)
             {
-                //    if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::packageStart(%s)\n", name);
+                _XXX("RC_SPEW_XML") << "XmlParser::packageStart(" << name << ")" << endl;
       
                 /* Only care about the containers here */
                 if (!strcmp((const char *)name, "history")) {
@@ -498,7 +497,7 @@ namespace zypp
                     _current_dep_list = _toplevel_dep_list = &_current_children;
                 } 
                 else {
-                    // if (getenv ("RC_SPEW_XML")) rc_debug (RC_DEBUG_LEVEL_ALWAYS, "! Not handling %s in package start", name);
+                    _XXX("RC_SPEW_XML") << "! Not handling " << name << " in package start" << endl;
                 }
             }
       
@@ -506,7 +505,7 @@ namespace zypp
             void
             XmlParser::historyStart(const char * name, const xmlChar **attrs)
             {
-                //    if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::historyStart(%s)\n", name);
+                _XXX("RC_SPEW_XML") << "XmlParser::historyStart(" << name << ")" << endl;
       
                 if (!strcmp(name, "update")) {
                     assert(_current_update == NULL);
@@ -516,7 +515,7 @@ namespace zypp
                     _state = PARSER_UPDATE;
                 }
                 else {
-                    if (getenv ("RC_SPEW_XML")) rc_debug (RC_DEBUG_LEVEL_ALWAYS, "! Not handling %s in history", name);
+                    _XXX("RC_SPEW_XML") << "! Not handling " << name << " in history" << endl;
                 }
             }
       
@@ -524,7 +523,7 @@ namespace zypp
             void
             XmlParser::dependencyStart(const char *name, const xmlChar **attrs)
             {
-                //    if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::dependencyStart(%s)\n", name);
+                _XXX("RC_SPEW_XML") << "XmlParser::dependencyStart(" << name << ")" << endl;
       
                 if (!strcmp(name, "dep")) {
                     Capability dep;
@@ -541,7 +540,7 @@ namespace zypp
                 else if (!strcmp(name, "or"))
                     _current_dep_list->clear();
                 else {
-                    if (getenv ("RC_SPEW_XML")) rc_debug (RC_DEBUG_LEVEL_ALWAYS, "! Not handling %s in dependency", name);
+                    _DBG("RC_SPEW_XML") <<  "! Not handling " << name << " in dependency" << endl;
                 }
             }
       
@@ -552,7 +551,7 @@ namespace zypp
             void
             XmlParser::packageEnd(const char *name)
             {
-                //    if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::packageEnd(%s)\n", name);
+                _XXX("RC_SPEW_XML") << "XmlParser::packageEnd(" << name << ")" << endl;
       
                 if (!strcmp(name, "package")) {
                     PackageUpdate_Ptr update = NULL;
@@ -600,7 +599,7 @@ namespace zypp
                     }
       
                     if (piter == _current_provides.end()) {                    // no self provide found, construct one
-                        //if (getenv ("RC_SPEW")) fprintf (stderr, "Adding self-provide [%s]\n", selfdep->asString().c_str());
+                        _XXX("RC_SPEW") << "Adding self-provide [" << selfdep.asString() << "]" << endl;
                         _current_provides.insert (selfdep);
                     }
 
@@ -634,9 +633,9 @@ namespace zypp
                     }
                     _all_packages.push_back (package);
        
-                    if (getenv ("RC_SPEW")) fprintf (stderr, "%s\n", package->asString(true).c_str());
-                    if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::packageEnd done: '%s'\n", package->asString(true).c_str());
-                    // if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::packageEnd now %ld packages\n", _all_packages.size());
+                    _DBG("RC_SPEW") << package->asString(true) << endl;
+                    _DBG("RC_SPEW_XML") << "XmlParser::packageEnd done: '" << package->asString(true) << "'" << endl;
+                    _XXX("RC_SPEW_XML") << "XmlParser::packageEnd now " << _all_packages.size() << " packages" << endl;
                     _current_package_stored = true;
                     _state = PARSER_TOPLEVEL;
                 }
@@ -651,10 +650,10 @@ namespace zypp
                 } else if (!strcmp(name, "install_only")) {            _current_package_installOnly = true;
                 } else if (!strcmp(name, "package_set")) {             _current_package_packageSet = true;
                 } else {
-                    if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::packageEnd(%s) unknown\n", name);
+                    _DBG("RC_SPEW_XML") << "XmlParser::packageEnd(" << name << ") unknown" << endl;
                 }
       
-                //    if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::packageEnd(%s) done\n", name);
+                _XXX("RC_SPEW_XML") << "XmlParser::packageEnd(" << name << ") done" << endl;
       
                 releaseBuffer();
             }
@@ -663,7 +662,7 @@ namespace zypp
             void
             XmlParser::historyEnd(const char *name)
             {
-                //    if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::historyEnd(%s)\n", name);
+                _XXX("RC_SPEW_XML") << "XmlParser::historyEnd(" << name << ")" << endl;
       
                 if (!strcmp(name, "history")) {
                     assert(_current_update == NULL);
@@ -676,7 +675,7 @@ namespace zypp
             void
             XmlParser::updateEnd(const char *name)
             {
-                //    if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::updateEnd(%s)\n", name);
+                _XXX("RC_SPEW_XML") << "XmlParser::updateEnd(" << name << ")" << endl;
       
                 Channel_constPtr channel;
                 const char *url_prefix = NULL;
@@ -725,7 +724,8 @@ namespace zypp
                     fprintf (stderr, "XmlParser::updateEnd(%s) unknown\n", name);
                 }
       
-                //    if (_current_update != NULL && getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::updateEnd(%s) => '%s'\n", name, _current_update->asString().c_str());
+                if (_current_update != NULL )
+                   _DBG("RC_SPEW_XML") << "XmlParser::updateEnd(" << name << ") => '" << _current_update->asString() << "'" << endl;
       
                 releaseBuffer();
       
@@ -735,7 +735,7 @@ namespace zypp
             void
             XmlParser::dependencyEnd(const char *name)
             {
-                //    if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::dependencyEnd(%s)\n", name);
+                _XXX("RC_SPEW_XML") << "XmlParser::dependencyEnd(" << name << ")" << endl;
       
                 if (!strcmp(name, "or")) {
 #if 0 
index ba651cc..ff8089d 100644 (file)
  * USA.
  */
 
-#include <zypp/solver/detail/extract.h>
-#include <zypp/solver/detail/XmlParser.h>
-#include <zypp/solver/detail/utils.h>
-#include <zypp/base/Logger.h>
-#include <zypp/solver/detail/debug.h>
+#include "zypp/solver/detail/extract.h"
+#include "zypp/solver/detail/XmlParser.h"
+#include "zypp/solver/detail/utils.h"
+#include "zypp/base/Logger.h"
 
 /////////////////////////////////////////////////////////////////////////
 namespace zypp 
@@ -154,7 +153,7 @@ namespace zypp
        return -1;
       
           if (!dump_node->equals("world")) {
-       debug (DEBUG_LEVEL_WARNING, "Unrecognized top-level node for undump: '%s'", dump_node->name());
+                         WAR << "Unrecognized top-level node for undump: '" << dump_node->name() << "'" << endl;
        return -1;
           }
       
@@ -485,7 +484,7 @@ namespace zypp
       {
       #ifndef  ENABLE_RPM
           /* We can't support yum without rpm support */
-          debug (RC_DEBUG_LEVEL_ERROR, "RPM support is not enabled");
+          ERR << "RPM support is not enabled" << endl;
           return NULL;
       #else
           RCRpmman *rpmman;
@@ -498,8 +497,7 @@ namespace zypp
           g_return_val_if_fail (packman != NULL, NULL);
       
           if (!g_type_is_a (G_TYPE_FROM_INSTANCE (packman), RC_TYPE_RPMMAN)) {
-       debug (RC_DEBUG_LEVEL_ERROR,
-                 "yum support is not available on non-RPM systems");
+                         DBG << "yum support is not available on non-RPM systems" << endl;
        return NULL;
           }
       
@@ -508,8 +506,7 @@ namespace zypp
           h = rpmman->headerLoad (data);
       
           if (h == NULL) {
-       debug (RC_DEBUG_LEVEL_ERROR,
-                 "Unable to get header from headerCopyLoad!");
+                         DBG << "Unable to get header from headerCopyLoad!" << endl;
        return NULL;
           }
       
@@ -543,7 +540,7 @@ namespace zypp
       {
       #ifndef ENABLE_RPM
           /* We can't support apt-rpm without rpm support */
-          debug (RC_DEBUG_LEVEL_ERROR, "RPM support is not enabled");
+          ERR << "RPM support is not enabled" << endl;
           return -1;
       #else
           RCRpmman *rpmman;
@@ -557,16 +554,14 @@ namespace zypp
           g_return_val_if_fail (packman != NULL, -1);
       
           if (!g_type_is_a (G_TYPE_FROM_INSTANCE (packman), RC_TYPE_RPMMAN)) {
-       debug (RC_DEBUG_LEVEL_ERROR,
-                 "apt-rpm support is not available on non-RPM systems");
+                         ERR << "apt-rpm support is not available on non-RPM systems" << endl;
        return -1;
           }
       
           rpmman = RC_RPMMAN (packman);
       
           if (len < hdrmagic_len) {
-       debug (RC_DEBUG_LEVEL_ERROR,
-                 "Data is too small to possibly be correct");
+                         ERR << "Data is too small to possibly be correct" << endl;
        return 0;
           }
       
@@ -596,8 +591,7 @@ namespace zypp
        h = rpmman->headerLoad (cur_ptr);
       
        if (h == NULL) {
-           debug (RC_DEBUG_LEVEL_ERROR,
-                     "Unable to get header from headerCopyLoad!");
+           ERR << "Unable to get header from headerCopyLoad!" << endl;
            return 0;
        }
       
@@ -606,7 +600,7 @@ namespace zypp
        if (n && typ == RPM_STRING_TYPE)
            archstr = tmpc;
        else {
-           debug (RC_DEBUG_LEVEL_WARNING, "No arch available!");
+           WAR << "No arch available!" << endl;
            goto cleanup;
        }