Author: jkupec Date: Fri Aug 10 10:25:26 2007 New Revision: 6564 URL: http://svn.opensuse.org/viewcvs/zypp?rev=6564&view=rev Log: - improved error reporting of init_repos and refresh_repos (#298506) - RuntimeData::limit_to_verbosity introduced Modified: trunk/zypper/src/zypper-source-callbacks.h trunk/zypper/src/zypper-sources.cc trunk/zypper/src/zypper.h Modified: trunk/zypper/src/zypper-source-callbacks.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-source-callbacks.h?rev=6564&r1=6563&r2=6564&view=diff ============================================================================== --- trunk/zypper/src/zypper-source-callbacks.h (original) +++ trunk/zypper/src/zypper-source-callbacks.h Fri Aug 10 10:25:26 2007 @@ -217,26 +217,30 @@ { void tick( const zypp::ProgressData &data ) { - //std::cout << "TICK!" << std::endl; + // verbosity filter + // don't display anything, if verbosity is not >= than limit_to_verbosity + if (gSettings.verbosity < gData.limit_to_verbosity) + return; + if ( data.reportAlive() ) - { display_tick (zypp::str::numstring(data.numericId()), cout, data.name() ); - } else - { display_progress ( zypp::str::numstring(data.numericId()), cout, data.name() , data.val() ); - } - - } virtual void start( const zypp::ProgressData &data ) { + if (gSettings.verbosity < gData.limit_to_verbosity) + return; + tick(data); } virtual bool progress( const zypp::ProgressData &data ) { + if (gSettings.verbosity < gData.limit_to_verbosity) + return true; + tick(data); return true; } @@ -250,6 +254,9 @@ virtual void finish( const zypp::ProgressData &data ) { + if (gSettings.verbosity < gData.limit_to_verbosity) + return; + display_done(zypp::str::numstring(data.numericId()), cout, data.name() ); } }; Modified: trunk/zypper/src/zypper-sources.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-sources.cc?rev=6564&r1=6563&r2=6564&view=diff ============================================================================== --- trunk/zypper/src/zypper-sources.cc (original) +++ trunk/zypper/src/zypper-sources.cc Fri Aug 10 10:25:26 2007 @@ -16,6 +16,7 @@ #include "zypper.h" #include "zypper-tabulator.h" #include "zypper-callbacks.h" +//#include "AliveCursor.h" #include "zypper-sources.h" using namespace std; @@ -72,7 +73,19 @@ } // --------------------------------------------------------------------------- - +/* +bool build_cache_callback(const ProgressData & pd) +{ + static AliveCursor cursor; + if ( pd.val() == 100 ) + cout << CLEARLN << cursor.done() << " " << pd.name(); + else + cout << CLEARLN << cursor++ << " " << pd.name(); + cout << " [" << pd.val() << "%] :O)"; + cout << flush; + return true; +} +*/ static bool build_cache(const RepoInfo &repo, bool force_build) { try @@ -162,6 +175,8 @@ // handle root user differently if (geteuid() == 0) { + // limit progress reporting only to verbosity level MEDIUM + gData.limit_to_verbosity = VERBOSITY_MEDIUM; if (refresh_raw_metadata(repo, false) || build_cache(repo, false)) { cerr << format(_("Disabling repository '%s' because of the above error.")) @@ -171,6 +186,8 @@ it->setEnabled(false); } + // restore verbosity limit + gData.limit_to_verbosity = VERBOSITY_NORMAL; } // non-root user else Modified: trunk/zypper/src/zypper.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper.h?rev=6564&r1=6563&r2=6564&view=diff ============================================================================== --- trunk/zypper/src/zypper.h (original) +++ trunk/zypper/src/zypper.h Fri Aug 10 10:25:26 2007 @@ -92,8 +92,7 @@ struct RuntimeData { RuntimeData() - : patches_count(0), - security_patches_count(0) + : patches_count(0), security_patches_count(0), limit_to_verbosity(0) {} std::list<Error> errors; @@ -104,12 +103,37 @@ std::vectorstd::string packages_to_uninstall; zypp::ResStore repo_resolvables; zypp::ResStore target_resolvables; + + /** + * Limit output to and above specified verbosity level. + * + * Use this variable to control whether to print the output or not, + * wherever the desired verbosity level is variable. Then set the limit + * before the code where the output is generated and reset it afterwards: + * + * <code> + * + * // set verbosity limit + * gData.limit_to_verbosity = VERBOSITY_MEDIUM; + * + * ... code generating the output but respecting the verbosity limit goes here ... + * + * // restore verbosity limit + * gData.limit_to_verbosity = VERBOSITY_NORMAL; + * + * </code> + */ + int limit_to_verbosity; }; extern RuntimeData gData; extern Settings gSettings; extern std::ostream no_stream; +#define VERBOSITY_NORMAL 0 +#define VERBOSITY_MEDIUM 1 +#define VERBOSITY_HIGH 2 + /** * Macro to filter output above the current verbosity level. * @@ -127,15 +151,15 @@ */ //!@{ //! normal output -#define cout_n COND_STREAM(cout, 0) +#define cout_n COND_STREAM(cout, VERBOSITY_NORMAL) //! verbose output -#define cout_v COND_STREAM(cout, 1) +#define cout_v COND_STREAM(cout, VERBOSITY_MEDIUM) //! verbose error output -#define cerr_v COND_STREAM(cerr, 1) +#define cerr_v COND_STREAM(cerr, VERBOSITY_MEDIUM) //! debug info output -#define cout_vv COND_STREAM(cout, 2) +#define cout_vv COND_STREAM(cout, VERBOSITY_HIGH) //! debug error output (details) -#define cerr_vv COND_STREAM(cerr, 2) +#define cerr_vv COND_STREAM(cerr, VERBOSITY_HIGH) //!@} // undefine _ macro from libzypp -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org