Log all messages to a recipe with the name of the corresponding test
authorJonatan Schlag <jonatan.schlag@ipfire.org>
Tue, 1 May 2018 08:23:20 +0000 (10:23 +0200)
committerJonatan Schlag <jonatan.schlag@ipfire.org>
Tue, 1 May 2018 08:23:20 +0000 (10:23 +0200)
Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
recipe.py

index 3a9b009..725e099 100644 (file)
--- a/recipe.py
+++ b/recipe.py
@@ -18,8 +18,14 @@ class RecipeExeption(Exception):
 class recipe():
     def __init__(self, path, circle=[]):
         self.recipe_file = path
-        self.log = logger.getChild(os.path.basename(self.recipe_file))
-        self.path = os.path.dirname(self.recipe_file)
+        try:
+            self.path = os.path.dirname(self.recipe_file)
+            self.name = os.path.basename(self.path)
+        except BaseException as e:
+            logger.error("Failed to get the name of the test to this recipe")
+            raise e
+
+        self.log = logger.getChild(self.name)
         self.log.debug("Path of recipe is: {}".format(self.recipe_file))
         self._recipe = None
         self._machines = None