consistent log handling when not using JSON loggers
our logger was never being quite hooked up when not using JSON loggers,
meaning that log messages (such as those fixed here to include newlines) were never shown.
MODIFY
repo2docker/app.py
repo2docker/app.py
@@ -497,17 +497,17 @@ class Repo2Docker(Application):
def initialize(self, *args, **kwargs):
"""Init repo2docker configuration before start"""
# FIXME: Remove this function, move it to setters / traitlet reactors
+ self.log = logging.getLogger("repo2docker")
+ self.log.setLevel(self.log_level)
+ logHandler = logging.StreamHandler()
+ self.log.handlers = []
+ self.log.addHandler(logHandler)
if self.json_logs:
# register JSON excepthook to avoid non-JSON output on errors
sys.excepthook = self.json_excepthook
# Need to reset existing handlers, or we repeat messages
- logHandler = logging.StreamHandler()
formatter = jsonlogger.JsonFormatter()
logHandler.setFormatter(formatter)
- self.log = logging.getLogger("repo2docker")
- self.log.handlers = []
- self.log.addHandler(logHandler)
- self.log.setLevel(self.log_level)
else:
# due to json logger stuff above,
# our log messages include carriage returns, newlines, etc.

MODIFY
repo2docker/buildpacks/conda/__init__.py
repo2docker/buildpacks/conda/__init__.py
@@ -154,7 +154,7 @@ class CondaBuildPack(BaseImage):
"conda/activate-conda.sh": "/etc/profile.d/activate-conda.sh",
}
py_version = self.python_version
- self.log.info("Building conda environment for python=%s" % py_version)
+ self.log.info("Building conda environment for python={py_version}\n")
# Select the frozen base environment based on Python version.
# avoids expensive and possibly conflicting upgrades when changing
# major Python versions during upgrade.
@@ -181,7 +181,7 @@ class CondaBuildPack(BaseImage):
frozen_name = py_frozen_name
pip_frozen_name = f"requirements.py-{py_version}.pip"
if not frozen_name:
- self.log.warning(f"No frozen env for {py_version}")
+ self.log.warning(f"No frozen env for {py_version}\n")
files[
"conda/" + frozen_name
] = self._nb_environment_file = "/tmp/env/environment.lock"

consistent log handling when not using JSON loggers

our logger was never being quite hooked up when not using JSON loggers,
meaning that log messages (such as those fixed here to include newlines) were never shown.