def get_log_from_container()

in pyscripts/docker_log_processor.py [0:0]


    def get_log_from_container(container_name, queue):
        """
        Gets log info from the Docker container then converts DateTime
            and puts each line in the queue.

        Parameters
        ----------
        container_name : string
            Name of the Docker container
        queue : object
            queue to stuff the log object in
        """
        client = docker.from_env()
        container = client.containers.get(container_name)

        for log_line in container.logs(
            stream=True, tail=0, follow=True, timestamps=True
        ):
            try:
                log_line = log_line.decode("utf8").strip()
                log_line_parts = log_line.split("Z ")

                if log_line_parts:
                    log_data = ""
                    num_parts = len(log_line_parts)

                    # Handle case where more than one timestamp
                    if num_parts > 2:
                        for part in range(1, num_parts):
                            log_data += log_line_parts[part] + " "
                    else:
                        log_data = log_line_parts[1]

                log_line_object = LogLineObject(
                    DockerLogProcessor.format_date_and_time(log_line_parts[0]),
                    container_name,
                    log_data,
                )
                queue.put(log_line_object)
            except Exception as e:
                DockerLogProcessor.write_err(
                    "Exception getting container log_line from: " + container_name
                )
                DockerLogProcessor.write_err(e)