seaworthy.stream.logs¶
-
stream_logs
(container, timeout=10.0, **logs_kwargs)[source]¶ Stream logs from a Docker container within a timeout.
Parameters: - container (Container) – Container who’s log lines to stream.
- timeout – Timeout value in seconds.
- logs_kwargs – Additional keyword arguments to pass to
container.logs()
. For example, thestdout
andstderr
boolean arguments can be used to determine whether to stream stdout or stderr or both (the default).
Raises: TimeoutError – When the timeout value is reached before the logs have completed.
-
wait_for_logs_matching
(container, matcher, timeout=10, encoding='utf-8', **logs_kwargs)[source]¶ Wait for matching log line(s) from the given container by streaming the container’s stdout and/or stderr outputs.
Each log line is decoded and any trailing whitespace is stripped before the line is matched.
Parameters: - container (Container) – Container who’s log lines to wait for.
- matcher – Callable that returns True once it has matched a decoded log line(s).
- timeout – Timeout value in seconds.
- encoding – Encoding to use when decoding container output to strings.
- logs_kwargs – Additional keyword arguments to pass to
container.logs()
. For example, thestdout
andstderr
boolean arguments can be used to determine whether to stream stdout or stderr or both (the default).
Returns: The final matching log line.
Raises: - TimeoutError – When the timeout value is reached before matching log lines have been found.
- RuntimeError – When all log lines have been consumed but matching log lines have not been found (the container must have stopped for its stream to have ended without error).