From: Jan Kupec Date: Fri, 10 Aug 2007 08:25:26 +0000 (+0000) Subject: - improved error reporting of init_repos and refresh_repos (#298506) X-Git-Tag: BASE-SuSE-Linux-10_3-Branch~170 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b928068116b58ca891565ee068e431b597d3a2b8;p=platform%2Fupstream%2Fzypper.git - improved error reporting of init_repos and refresh_repos (#298506) - RuntimeData::limit_to_verbosity introduced --- diff --git a/src/zypper-source-callbacks.h b/src/zypper-source-callbacks.h index e44225f..e4e1afd 100644 --- a/src/zypper-source-callbacks.h +++ b/src/zypper-source-callbacks.h @@ -217,26 +217,30 @@ struct ProgressReportReceiver : public zypp::callback::ReceiveReport= 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 @@ struct ProgressReportReceiver : public zypp::callback::ReceiveReportsetEnabled(false); } + // restore verbosity limit + gData.limit_to_verbosity = VERBOSITY_NORMAL; } // non-root user else diff --git a/src/zypper.h b/src/zypper.h index 959c734..f6a7838 100644 --- a/src/zypper.h +++ b/src/zypper.h @@ -92,8 +92,7 @@ struct Error struct RuntimeData { RuntimeData() - : patches_count(0), - security_patches_count(0) + : patches_count(0), security_patches_count(0), limit_to_verbosity(0) {} std::list errors; @@ -104,12 +103,37 @@ struct RuntimeData std::vector 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: + * + * + * + * // 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; + * + * + */ + 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 @@ extern std::ostream no_stream; */ //!@{ //! 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