added levels for verbose

This commit is contained in:
Andrei Yankovich 2019-03-28 18:58:36 +03:00
parent 02d3e66885
commit bd62cda55f
3 changed files with 40 additions and 6 deletions

View File

@ -51,5 +51,5 @@ DISTFILES += \
RESOURCES += \
res.qrc
VERSION = 1.1.3
VERSION = 1.1.4

View File

@ -25,13 +25,40 @@ bool Params::isEndable(const QString& key) {
return params.contains(key);
}
void Params::verboseLog(const QString &log) {
void Params::verboseLog(const QString &log, VerboseLvl vLvl) {
if (isEndable("verbose")) {
qDebug() << "verbose log: " + log ;
auto lvl = static_cast<VerboseLvl>(getArg("verbose").toInt());
if (vLvl <= lvl) {
switch (vLvl) {
case VerboseLvl::Error: {
qCritical() << "Error: " + log;
break;
}
case VerboseLvl::Warning: {
qWarning() << "Warning: " + log;
break;
}
case VerboseLvl::Info: {
qInfo() << "Info: " + log;
break;
}
default: {
qDebug() << "Verbose log: " + log ;
break;
}
}
}
}
}
bool Params::parseParams(int argc, char *argv[]) {
bool Params::parseParams(int argc,const char *argv[]) {
params.clear();
#ifdef Q_OS_WIN

View File

@ -18,6 +18,13 @@ namespace QuasarAppUtils {
* @brief The Params class for parese app params
*/
enum VerboseLvl {
Debug = 0x0,
Error = 0x1,
Warning = 0x2,
Info = 0x3,
};
class QUASARAPPSHARED_EXPORT Params
{
public:
@ -29,7 +36,7 @@ public:
* @param argv - arrat of arguments
* @return true if all arguments read else false
*/
static bool parseParams(int argc, char *argv[]);
static bool parseParams(int argc, const char *argv[]);
/**
* @brief getStrArg - get string value of key
@ -56,7 +63,7 @@ public:
* @brief verboseLog - print text on console if the flag "vergose" is enabled
* @param log - printed text
*/
static void verboseLog(const QString& log);
static void verboseLog(const QString& log, VerboseLvl vLvl = VerboseLvl::Debug);
};
}