aboutsummaryrefslogtreecommitdiff
path: root/include/armnn/Logging.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/armnn/Logging.hpp')
-rw-r--r--include/armnn/Logging.hpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/include/armnn/Logging.hpp b/include/armnn/Logging.hpp
index 27971c56e4..9a60e07c63 100644
--- a/include/armnn/Logging.hpp
+++ b/include/armnn/Logging.hpp
@@ -7,6 +7,7 @@
#include <armnn/Utils.hpp>
#include <iostream>
+#include <algorithm>
namespace armnn
{
@@ -32,6 +33,44 @@ inline std::string LevelToString(LogSeverity level)
}
}
+inline LogSeverity StringToLogLevel(std::string level)
+{
+ // Transfer to lower case
+ std::transform(level.begin(), level.end(), level.begin(),
+ [](unsigned char c){ return std::tolower(c); }
+ );
+
+ if (level == "trace")
+ {
+ return LogSeverity::Trace;
+ }
+ else if (level == "debug")
+ {
+ return LogSeverity::Debug;
+ }
+ else if (level == "info")
+ {
+ return LogSeverity::Info;
+ }
+ else if (level == "warning")
+ {
+ return LogSeverity::Warning;
+ }
+ else if (level == "error")
+ {
+ return LogSeverity::Error;
+ }
+ else if (level == "fatal")
+ {
+ return LogSeverity::Fatal;
+ }
+ else
+ {
+ throw armnn::Exception("Unknown severity level for logging: '" + level +
+ "'. Valid options: trace, debug, info, warning, error, fatal");
+ }
+}
+
class LogSink
{
public: