{
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;
}
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() );
}
};
#include "zypper.h"
#include "zypper-tabulator.h"
#include "zypper-callbacks.h"
+//#include "AliveCursor.h"
#include "zypper-sources.h"
using namespace std;
}
// ---------------------------------------------------------------------------
-
+/*
+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
// 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."))
it->setEnabled(false);
}
+ // restore verbosity limit
+ gData.limit_to_verbosity = VERBOSITY_NORMAL;
}
// non-root user
else
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;
std::vector<std::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.
*
*/
//!@{
//! 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