Commit 1df2b8ee authored by Nguyen, Thien's avatar Nguyen, Thien
Browse files

Added logging level getter


Signed-off-by: Nguyen, Thien's avatarThien Nguyen <nguyentm@ornl.gov>
parent 227da88c
......@@ -270,6 +270,17 @@ void XACCLogger::setLoggingLevel(int level) {
}
}
int XACCLogger::getLoggingLevel() {
const auto spdLevel = getLogger()->level();
switch (spdLevel) {
case spdlog::level::trace:
case spdlog::level::debug: return 2;
case spdlog::level::info: return 1;
default:
return 0;
}
}
void XACCLogger::info(const std::string &msg, MessagePredicate predicate) {
if (useCout) {
if (predicate() && globalPredicate()) {
......
......@@ -201,6 +201,7 @@ public:
// 2: Debug and above
// Note: this will only take effect when xacc::verbose is set.
void setLoggingLevel(int level);
int getLoggingLevel();
void subscribeLoggingLevel(LoggingLevelNotification onLevelChangeFn) {
loggingLevelSubscribers.emplace_back(onLevelChangeFn);
......
......@@ -119,6 +119,10 @@ void setLoggingLevel(int level) {
XACCLogger::instance()->setLoggingLevel(level);
}
int getLoggingLevel() {
return XACCLogger::instance()->getLoggingLevel();
}
void subscribeLoggingLevel(LoggingLevelNotification callback) {
XACCLogger::instance()->subscribeLoggingLevel(callback);
}
......
......@@ -97,6 +97,7 @@ void addCommandLineOptions(const std::map<std::string, std::string> &options);
void setGlobalLoggerPredicate(MessagePredicate predicate);
void logToFile(bool enable);
void setLoggingLevel(int level);
int getLoggingLevel();
void subscribeLoggingLevel(LoggingLevelNotification callback);
void info(const std::string &msg,
......
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