diff options
author | jardellos <thierry.hardy@orange.com> | 2020-08-28 11:27:47 +0200 |
---|---|---|
committer | Thierry Hardy <thierry.hardy@orange.com> | 2020-08-31 13:49:40 +0200 |
commit | 7664059073dd0691428864deb37c3861521e2cd8 (patch) | |
tree | 8817d8115de3846dee9a5f3a591ecf536e8147d6 /src/onaptests/steps/base.py | |
parent | f9b0c349a5c83f9278f6b115d334598201d9d7e6 (diff) |
Add logger in python-sdktests
Adding of logger to onaptests setting the stream and file handlers based
on settings.py
onapsdk should evolve to include the same code
This would avoid to add it in run.py
Simplification of the proposal based on remarks from Michal and Morgan
Issue-ID: TEST-252
Signed-off-by: jardellos <thierry.hardy@orange.com>
Change-Id: I5b7baf77580df916c4f5e62965a47d8462b44c43
Diffstat (limited to 'src/onaptests/steps/base.py')
-rw-r--r-- | src/onaptests/steps/base.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/onaptests/steps/base.py b/src/onaptests/steps/base.py index b32e6d3..5f66935 100644 --- a/src/onaptests/steps/base.py +++ b/src/onaptests/steps/base.py @@ -1,10 +1,24 @@ +import logging +import logging.config + from abc import ABC, abstractmethod from typing import List - +from onapsdk.configuration import settings class BaseStep(ABC): """Base step class.""" + _logger: logging.Logger = logging.getLogger("") + + def __init_subclass__(cls): + """Subclass initialization. + + Add _logger property for any BaseStep subclass + """ + super().__init_subclass__() + cls._logger: logging.Logger = logging.getLogger("") + logging.config.dictConfig(settings.LOG_CONFIG) + def __init__(self, cleanup: bool = False) -> None: """Step initialization. @@ -16,6 +30,8 @@ class BaseStep(ABC): self._cleanup: bool = cleanup self._parent: "BaseStep" = None + + def add_step(self, step: "BaseStep") -> None: """Add substep. |