lib: set component's initial log level when adding it to the graph
[babeltrace.git] / src / bindings / python / bt2 / bt2 / utils.py
index b564fcad1b486aa57ae2b27ca613d6ff3f517eb9..4329d93fa17565f31dcf4aaec06e33a5e1132c36 100644 (file)
@@ -21,6 +21,7 @@
 # THE SOFTWARE.
 
 import bt2
+import bt2.logging
 
 
 def _check_bool(o):
@@ -125,3 +126,20 @@ def _handle_ret(ret, msg=None):
 def _handle_ptr(ptr, msg=None):
     if ptr is None:
         _raise_bt2_error(msg)
+
+
+def _check_log_level(log_level):
+    _check_int(log_level)
+
+    log_levels = (
+        bt2.logging.LoggingLevel.VERBOSE,
+        bt2.logging.LoggingLevel.DEBUG,
+        bt2.logging.LoggingLevel.INFO,
+        bt2.logging.LoggingLevel.WARN,
+        bt2.logging.LoggingLevel.ERROR,
+        bt2.logging.LoggingLevel.FATAL,
+        bt2.logging.LoggingLevel.NONE,
+    )
+
+    if log_level not in log_levels:
+        raise ValueError("'{}' is not a valid logging level".format(log_level))
This page took 0.024481 seconds and 4 git commands to generate.