Commit a677316c authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

adding warning function to api


Signed-off-by: Mccaskey, Alex's avatarAlex McCaskey <mccaskeyaj@ornl.gov>
parent 8c776c19
......@@ -113,6 +113,10 @@ void info(const std::string& msg, MessagePredicate predicate) {
XACCLogger::instance()->info(msg, predicate);
}
void warning(const std::string& msg, MessagePredicate predicate) {
XACCLogger::instance()->warning(msg, predicate);
}
void debug(const std::string& msg, MessagePredicate predicate) {
XACCLogger::instance()->debug(msg, predicate);
}
......
......@@ -116,6 +116,14 @@ void setGlobalLoggerPredicate(MessagePredicate predicate);
*/
void info(const std::string& msg, MessagePredicate predicate = std::function<bool(void)>([]() {return true;}));
/**
* Print a warning log to the XACC Logger.
*
* @param msg The log to print
* @param predicate Function with no arguments that returns bool
*/
void warning(const std::string& msg, MessagePredicate predicate = std::function<bool(void)>([]() {return true;}));
/**
* Print an debug log to the XACC Logger.
*
......
......@@ -98,6 +98,27 @@ void XACCLogger::info(const std::string& msg, MessagePredicate predicate) {
}
}
}
void XACCLogger::warning(const std::string& msg, MessagePredicate predicate) {
if (useCout) {
if (predicate() && globalPredicate()) {
if (useColor) {
std::cout << "\033[1;33m[XACC Warning] " + msg + "\033[0m \n";
} else {
std::cout << "[XACC Warning] " + msg + "\n";
}
}
} else {
if (predicate() && globalPredicate()) {
if (useColor) {
logger->info("\033[1;33m" + msg + "\033[0m");
} else {
logger->info(msg);
}
}
}
}
void XACCLogger::debug(const std::string& msg, MessagePredicate predicate) {
if (useCout) {
if (predicate() && globalPredicate()) {
......@@ -110,7 +131,7 @@ void XACCLogger::debug(const std::string& msg, MessagePredicate predicate) {
} else {
if (predicate() && globalPredicate()) {
if (useColor) {
logger->info("\033[1;33m" + msg + "\033[0m");
logger->info("\033[1;32m" + msg + "\033[0m");
} else {
logger->info(msg);
}
......
......@@ -134,6 +134,7 @@ public:
}
void setGlobalLoggerPredicate(MessagePredicate pred) {globalPredicate = pred;}
void info(const std::string& msg, MessagePredicate predicate = std::function<bool(void)>([]() {return true;}));
void warning(const std::string& msg, MessagePredicate predicate = std::function<bool(void)>([]() {return true;}));
void debug(const std::string& msg, MessagePredicate predicate = std::function<bool(void)>([]() {return true;}));
void error(const std::string& msg, MessagePredicate predicate = std::function<bool(void)>([]() {return true;}));
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment