Browse Source

Enable setting LogLevels

bernhardbuhl 4 years ago
parent
commit
c52dc6f7ca

+ 0 - 2
baangt/__init__.py

@@ -21,7 +21,6 @@ from baangt.base.Timing.hookImpls import TimingHookImpl
 from baangt.base.ExportResults.hookImpls import \
     (ExportResultsHookImpl, ExcelSheetHelperFunctionsHookImpl, ExportTimingHookImpl)
 
-
 plugin_manager.register(plugin=TestRunHookImpl())
 plugin_manager.register(plugin=BrowserDriverHookImpl())
 plugin_manager.register(plugin=TimingHookImpl())
@@ -29,7 +28,6 @@ plugin_manager.register(plugin=ExportResultsHookImpl())
 plugin_manager.register(plugin=ExcelSheetHelperFunctionsHookImpl())
 plugin_manager.register(plugin=ExportTimingHookImpl())
 
-
 # fixme: Parameter für Logfile should include stage and browser()
 managedPaths = ManagedPaths()
 logFilename:pathlib.Path = Path(managedPaths.getLogfilePath())

+ 1 - 0
baangt/base/GlobalConstants.py

@@ -68,6 +68,7 @@ SCREENSHOTS = "Screenshots"
 EXECUTION_DONTCLOSEBROWSER = "dontCloseBrowser"
 EXECUTION_SLOW = "slowExecution"
 EXECUTION_NETWORK_INFO = 'NetworkInfo'
+EXECUTION_LOGLEVEL = "LogLevel"
 
 EXECUTION_STAGE = 'Stage'
 EXECUTION_STAGE_TEST = 'Test'

+ 5 - 2
baangt/base/TestRun/TestRun.py

@@ -225,12 +225,12 @@ class TestRun:
                     logger.info(f"TC is already in status Error - not processing steps {counterName}: {key}, {value}"
                                 f"and everything behind this step")
                     return
-                if kwargs[GC.KWARGS_DATA][GC.TESTCASESTATUS_STOP]:
+                if kwargs[GC.KWARGS_DATA].get(GC.TESTCASESTATUS_STOP):
                     logger.info(f"TC wanted to stop. Not processing steps {counterName}: {key}, {value}"
                                 f"and everything behind this step. TC-Status is "
                                 f"{kwargs[GC.KWARGS_DATA][GC.TESTCASESTATUS]}")
                     return
-                if kwargs[GC.KWARGS_DATA][GC.TESTCASESTATUS_STOPERROR]:
+                if kwargs[GC.KWARGS_DATA].get(GC.TESTCASESTATUS_STOPERROR):
                     kwargs[GC.KWARGS_DATA][GC.TESTCASESTATUS] = GC.TESTCASESTATUS_ERROR
                     if not kwargs[GC.KWARGS_DATA].get(GC.TESTCASEERRORLOG):
                         kwargs[GC.KWARGS_DATA][GC.TESTCASEERRORLOG] = "Aborted by command 'TCStopTestCaseError'"
@@ -308,6 +308,9 @@ class TestRun:
                     # This could be the "old" way of the globals-file (with {"HEADLESS":"True"})
                     self.globalSettings[key] = value
 
+        if self.globalSettings.get("TC.LogLevel"):
+            utils.setLogLevel(self.globalSettings.get("TC.LogLevel"))
+
     def _loadJSONTestRunDefinitions(self):
         if not self.testRunFileName and not self.testRunDict:  # -- API support: testRunDict --
             return

+ 5 - 0
baangt/base/Utils.py

@@ -90,6 +90,11 @@ class utils:
         return data
 
     @staticmethod
+    def setLogLevel(level):
+        logger.info(f"Changing Loglevel from {logger.level} to {level}")
+        logger.setLevel(level=level)
+
+    @staticmethod
     def listToString(completeList):
         """
         Returns a concatenated string from a list-object

+ 2 - 1
examples/globalsFullExample.json

@@ -17,5 +17,6 @@
     "CL.browserHandling": "baangt.base.BrowserHandling.BrowserHandling.BrowserDriver",
     "CL.testCaseSequenceMaster": "baangt.TestCaseSequenceMaster.TestCaseSequenceMaster",
     "TC.TestStepClass": "",
-    "TC.TestDataFileName": ""
+    "TC.TestDataFileName": "",
+    "TC.ExecutionLogLevel": "Info"
 }

+ 7 - 0
globalSetting.json

@@ -128,6 +128,13 @@
             "type": "text",
             "default": "",
             "displayText": "Datafile"
+        },
+        "TC.ExecutionLogLevel": {
+            "hint": "Set the level of logging. Standard = 'debug'. For production you might want to change to another value",
+            "type": "select",
+            "default": "Debug",
+            "options": ["Debug", "Info", "Warning", "Error"],
+            "displayText": "LogLevel"
         }
     }
 }