How to use the nox.logger.logger.info function in nox

To help you get started, we’ve selected a few nox examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github theacodes / nox / tests / test_logger.py View on Github external
def test_formatter(caplog):
    caplog.clear()
    logger.setup_logging(True, verbose=True)
    with caplog.at_level(logging.DEBUG):
        logger.logger.info("bar")
        logger.logger.output("foo")

    logs = [rec for rec in caplog.records if rec.levelname in ("INFO", "OUTPUT")]
    assert len(logs) == 1

    caplog.clear()
    with caplog.at_level(logger.OUTPUT):
        logger.logger.info("bar")
        logger.logger.output("foo")

    logs = [rec for rec in caplog.records if rec.levelname in ("INFO", "OUTPUT")]
    assert len(logs) == 2

    logs = [rec for rec in caplog.records if rec.levelname == "OUTPUT"]
    assert len(logs) == 1
    # Make sure output level log records are not nox prefixed
github theacodes / nox / tests / test_logger.py View on Github external
def test_formatter(caplog):
    caplog.clear()
    logger.setup_logging(True, verbose=True)
    with caplog.at_level(logging.DEBUG):
        logger.logger.info("bar")
        logger.logger.output("foo")

    logs = [rec for rec in caplog.records if rec.levelname in ("INFO", "OUTPUT")]
    assert len(logs) == 1

    caplog.clear()
    with caplog.at_level(logger.OUTPUT):
        logger.logger.info("bar")
        logger.logger.output("foo")

    logs = [rec for rec in caplog.records if rec.levelname in ("INFO", "OUTPUT")]
    assert len(logs) == 2

    logs = [rec for rec in caplog.records if rec.levelname == "OUTPUT"]
    assert len(logs) == 1
    # Make sure output level log records are not nox prefixed
    assert "nox" not in logs[0].message
github theacodes / nox / nox / virtualenv.py View on Github external
if not self._clean_location():
            logger.debug(
                "Re-using existing virtual environment at {}.".format(
                    self.location_name
                )
            )
            return False

        if self.venv_or_virtualenv == "virtualenv":
            cmd = [sys.executable, "-m", "virtualenv", self.location]
            if self.interpreter:
                cmd.extend(["-p", self._resolved_interpreter])
        else:
            cmd = [self._resolved_interpreter, "-m", "venv", self.location]

        logger.info(
            "Creating virtual environment ({}) using {} in {}".format(
                self.venv_or_virtualenv,
                os.path.basename(self._resolved_interpreter),
                self.location_name,
            )
        )
        nox.command.run(cmd, silent=True, log=False)

        return True
github theacodes / nox / nox / sessions.py View on Github external
def log(self, *args, **kwargs):
        """Outputs a log during the session."""
        logger.info(*args, **kwargs)
github theacodes / nox / nox / command.py View on Github external
log=True,
    external=False,
    **popen_kws
):
    """Run a command-line program."""

    if success_codes is None:
        success_codes = [0]

    cmd, args = args[0], args[1:]
    full_cmd = "{} {}".format(cmd, " ".join(args))

    cmd_path = which(cmd, path)

    if log:
        logger.info(full_cmd)

        is_external_tool = path is not None and not cmd_path.startswith(path)
        if is_external_tool:
            if external == "error":
                logger.error(
                    "Error: {} is not installed into the virtualenv, it is located at {}. "
                    "Pass external=True into run() to explicitly allow this.".format(
                        cmd, cmd_path
                    )
                )
                raise CommandFailed("External program disallowed.")
            elif external is False:
                logger.warning(
                    "Warning: {} is not installed into the virtualenv, it is located at {}. This might cause issues! "
                    "Pass external=True into run() to silence this message.".format(
                        cmd, cmd_path
github theacodes / nox / nox / sessions.py View on Github external
def log(self, message):
        """Log a message using the appropriate log function.

        Args:
            message (str): The message to be logged.
        """
        log_function = logger.info
        if self.status == Status.SUCCESS:
            log_function = logger.success
        if self.status == Status.SKIPPED:
            log_function = logger.warning
        if self.status.value <= 0:
            log_function = logger.error
        log_function(message)