in composer_local_dev/environment.py [0:0]
def logs(self, follow, max_lines):
"""
Fetch and print logs from the running composer local environment.
Container `logs` method returns blocking generator if follow is True,
and byte-decoded string if follow is False. That's why we need two
methods of handling and decoding logs.
"""
log_lines = self.get_container(self.container_name).logs(
timestamps=True,
stream=follow,
follow=follow,
tail=max_lines,
)
if follow:
LOG.debug(
"Printing previous %s lines and following output "
"from the container logs:",
max_lines,
)
for line in log_lines:
line = line.decode("utf-8").strip()
console.get_console().print(line)
else:
LOG.debug(
"Printing previous %s lines from container logs:", max_lines
)
log_lines = log_lines.decode("utf-8")
for line in log_lines.split("\n"):
console.get_console().print(line)