Allow setting libsolvs debugmask via $LIBSOLV_DEBUGMASK
authorMichael Andres <ma@suse.de>
Wed, 4 Dec 2013 11:41:50 +0000 (12:41 +0100)
committerMichael Andres <ma@suse.de>
Wed, 4 Dec 2013 11:41:50 +0000 (12:41 +0100)
doc/autoinclude/EnvironmentVariables.doc
zypp/sat/detail/PoolImpl.cc

index 3608426..0050e48 100644 (file)
@@ -23,6 +23,7 @@ Note that for Boolean variables we usually test whether the variable exists and
 \li \c ZYPP_FULLLOG=1 Even more verbose logging (usually not needed).
 \li \c ZYPP_LIBSOLV_FULLLOG=1 Verbose logging when resolving dependencies.
 \li (\c ZYPP_LIBSAT_FULLLOG=1) deprecated since \c libzypp-10.x, prefer \c ZYPP_LIBSOLV_FULLLOG
+\li \c LIBSOLV_DEBUGMASK=<INT> Pass value to libsolv::pool_setdebugmask
 
 \li \c ZYPP_MEDIA_CURL_DEBUG=<1|2> Log http headers, if \c 2 also log server responses.
 
index 622d199..0746b2d 100644 (file)
@@ -48,7 +48,17 @@ using std::endl;
 
 // ///////////////////////////////////////////////////////////////////
 namespace zypp
-{ /////////////////////////////////////////////////////////////////
+{
+  /////////////////////////////////////////////////////////////////
+  namespace env
+  {
+    /**  */
+    inline int LIBSOLV_DEBUGMASK()
+    {
+      const char * envp = getenv("LIBSOLV_DEBUGMASK");
+      return envp ? str::strtonum<int>( envp ) : 0;
+    }
+  } // namespace env
   ///////////////////////////////////////////////////////////////////
   namespace sat
   { /////////////////////////////////////////////////////////////////
@@ -181,12 +191,19 @@ namespace zypp
           ZYPP_THROW( Exception( _("Can not create sat-pool.") ) );
         }
         // initialialize logging
-       if ( getenv("ZYPP_LIBSOLV_FULLLOG") || getenv("ZYPP_LIBSAT_FULLLOG") )
-         ::pool_setdebuglevel( _pool, 4 );
-       else if ( getenv("ZYPP_FULLLOG") )
-         ::pool_setdebuglevel( _pool, 2 );
+       if ( env::LIBSOLV_DEBUGMASK() )
+       {
+         ::pool_setdebugmask(_pool, env::LIBSOLV_DEBUGMASK() );
+       }
        else
-         ::pool_setdebugmask(_pool, SOLV_DEBUG_JOB|SOLV_DEBUG_STATS);
+       {
+         if ( getenv("ZYPP_LIBSOLV_FULLLOG") || getenv("ZYPP_LIBSAT_FULLLOG") )
+           ::pool_setdebuglevel( _pool, 3 );
+         else if ( getenv("ZYPP_FULLLOG") )
+           ::pool_setdebuglevel( _pool, 2 );
+         else
+           ::pool_setdebugmask(_pool, SOLV_DEBUG_JOB|SOLV_DEBUG_STATS );
+       }
 
         ::pool_setdebugcallback( _pool, logSat, NULL );