diff --git a/src/molecule/command/idempotence.py b/src/molecule/command/idempotence.py index 3fbff5ecf0..117de3bd78 100644 --- a/src/molecule/command/idempotence.py +++ b/src/molecule/command/idempotence.py @@ -83,7 +83,7 @@ def execute(self): idempotent = self._is_idempotent(output) if idempotent: msg = "Idempotence completed successfully." - LOG.success(msg) + LOG.info(msg) else: msg = ( "Idempotence test failed because of the following tasks:\n" u"{}" diff --git a/src/molecule/command/init/role.py b/src/molecule/command/init/role.py index 3e88fd2ab3..8dfcb1b3ac 100644 --- a/src/molecule/command/init/role.py +++ b/src/molecule/command/init/role.py @@ -89,7 +89,7 @@ def execute(self): role_directory = os.path.join(role_directory, role_name) msg = "Initialized role in {} successfully.".format(role_directory) - LOG.success(msg) + LOG.info(msg) @command_base.click_command_ex() diff --git a/src/molecule/command/init/scenario.py b/src/molecule/command/init/scenario.py index 72f6a2c247..b6d400f710 100644 --- a/src/molecule/command/init/scenario.py +++ b/src/molecule/command/init/scenario.py @@ -112,7 +112,7 @@ def execute(self): role_directory = os.path.join(role_directory, role_name) msg = "Initialized scenario in {} successfully.".format(scenario_directory) - LOG.success(msg) + LOG.info(msg) def _role_exists(ctx, param, value): # pragma: no cover diff --git a/src/molecule/dependency/base.py b/src/molecule/dependency/base.py index c6c13fac68..420f312dc7 100644 --- a/src/molecule/dependency/base.py +++ b/src/molecule/dependency/base.py @@ -55,7 +55,7 @@ def execute_with_retries(self): # print(555, self._sh_command) util.run_command(self._sh_command, debug=self._config.debug) msg = "Dependency completed successfully." - LOG.success(msg) + LOG.info(msg) return except Exception: pass @@ -72,7 +72,7 @@ def execute_with_retries(self): try: util.run_command(self._sh_command, debug=self._config.debug) msg = "Dependency completed successfully." - LOG.success(msg) + LOG.info(msg) return except Exception as _exception: exception = _exception diff --git a/src/molecule/logger.py b/src/molecule/logger.py index 47aad11c3d..1b8b0894b7 100644 --- a/src/molecule/logger.py +++ b/src/molecule/logger.py @@ -26,9 +26,6 @@ from enrich.console import Console from enrich.logging import RichHandler -from molecule.console import console -from molecule.text import chomp - SUCCESS = 100 OUT = 101 @@ -45,29 +42,6 @@ def filter(self, logRecord): # pragma: no cover return logRecord.levelno <= self.__level -class CustomLogger(logging.getLoggerClass()): # type: ignore # see https://sam.hooke.me/note/2020/03/mypy-and-verbose-logging/ - """ - A custom logging class which adds additional methods to the logger. - - These methods serve as syntactic sugar for formatting log messages. - """ - - def __init__(self, name, level=logging.NOTSET): - """Construct CustomLogger.""" - super(CustomLogger, self).__init__(name, level=level) - logging.addLevelName(SUCCESS, "SUCCESS") - logging.addLevelName(OUT, "OUT") - - def success(self, msg, *args, **kwargs): - if self.isEnabledFor(SUCCESS): - self._log(SUCCESS, msg, args, **kwargs) - - def out(self, msg, *args, **kwargs): - msg = chomp(msg) - if self.isEnabledFor(OUT): - console.print(msg, args, **kwargs) - - class TrailingNewlineFormatter(logging.Formatter): """A custom logging formatter which removes additional newlines from messages.""" @@ -86,8 +60,6 @@ def get_logger(name=None) -> logging.Logger: name, ``__name__``. :return: logger object """ - logging.setLoggerClass(CustomLogger) - logger = logging.getLogger(name) # type: logging.Logger logger.setLevel(logging.DEBUG) diff --git a/src/molecule/provisioner/ansible_playbook.py b/src/molecule/provisioner/ansible_playbook.py index 6f21f29ffb..e863a57e6a 100644 --- a/src/molecule/provisioner/ansible_playbook.py +++ b/src/molecule/provisioner/ansible_playbook.py @@ -18,7 +18,6 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. """Ansible-Playbook Provisioner Module.""" - from molecule import logger, util LOG = logger.get_logger(__name__) @@ -27,24 +26,18 @@ class AnsiblePlaybook(object): """Privisioner Playbook.""" - def __init__(self, playbook, config, out=LOG.out, err=LOG.error): + def __init__(self, playbook, config): """ Set up the requirements to execute ``ansible-playbook`` and returns \ None. :param playbook: A string containing the path to the playbook. :param config: An instance of a Molecule config. - :param out: An optional function to process STDOUT for underlying - :func:``sh`` call. - :param err: An optional function to process STDERR for underlying - :func:``sh`` call. :returns: None """ self._ansible_command = None self._playbook = playbook self._config = config - self._out = out - self._err = err self._cli = {} self._env = self._config.provisioner.env diff --git a/src/molecule/test/functional/conftest.py b/src/molecule/test/functional/conftest.py index 9b700e0fd8..ebcab1c4a1 100644 --- a/src/molecule/test/functional/conftest.py +++ b/src/molecule/test/functional/conftest.py @@ -73,7 +73,7 @@ def with_scenario(request, scenario_to_test, driver_name, scenario_name, skip_te yield if scenario_name: msg = "CLEANUP: Destroying instances for all scenario(s)" - LOG.out(msg) + LOG.info(msg) cmd = ["molecule", "destroy", "--driver-name", driver_name, "--all"] assert run_command(cmd).returncode == 0 diff --git a/src/molecule/test/unit/conftest.py b/src/molecule/test/unit/conftest.py index 7039330405..0b70521f5e 100644 --- a/src/molecule/test/unit/conftest.py +++ b/src/molecule/test/unit/conftest.py @@ -167,11 +167,6 @@ def patched_logger_debug(mocker): return mocker.patch("logging.Logger.debug") -@pytest.fixture -def patched_logger_out(mocker): - return mocker.patch("molecule.logger.CustomLogger.out") - - @pytest.fixture def patched_logger_warning(mocker): return mocker.patch("logging.Logger.warning") @@ -187,11 +182,6 @@ def patched_logger_critical(mocker): return mocker.patch("logging.Logger.critical") -@pytest.fixture -def patched_logger_success(mocker): - return mocker.patch("molecule.logger.CustomLogger.success") - - @pytest.fixture def patched_run_command(mocker): m = mocker.patch("molecule.util.run_command") diff --git a/src/molecule/verifier/ansible.py b/src/molecule/verifier/ansible.py index a9a04c5e57..ecf4ef437c 100644 --- a/src/molecule/verifier/ansible.py +++ b/src/molecule/verifier/ansible.py @@ -82,7 +82,7 @@ def execute(self): self._config.provisioner.verify() msg = "Verifier completed successfully." - log.success(msg) + log.info(msg) def schema(self): return { diff --git a/src/molecule/verifier/testinfra.py b/src/molecule/verifier/testinfra.py index 63f8969433..5203bdcb61 100644 --- a/src/molecule/verifier/testinfra.py +++ b/src/molecule/verifier/testinfra.py @@ -186,7 +186,7 @@ def execute(self): result = util.run_command(self._testinfra_command, debug=self._config.debug) if result.returncode == 0: msg = "Verifier completed successfully." - LOG.success(msg) + LOG.info(msg) else: util.sysexit(result.returncode)