mirror of
https://github.com/QuasarApp/QuasarAppLib.git
synced 2025-04-26 09:44:38 +00:00
added levels for verbose
This commit is contained in:
parent
02d3e66885
commit
bd62cda55f
@ -51,5 +51,5 @@ DISTFILES += \
|
||||
RESOURCES += \
|
||||
res.qrc
|
||||
|
||||
VERSION = 1.1.3
|
||||
VERSION = 1.1.4
|
||||
|
||||
|
33
params.cpp
33
params.cpp
@ -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
|
||||
|
11
params.h
11
params.h
@ -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);
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user