Skip to content

Commit

Permalink
feat: add docker compose log
Browse files Browse the repository at this point in the history
  • Loading branch information
aleneum committed Dec 5, 2024
1 parent 833e268 commit d9ee959
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions hive_cli/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@ def get_container_states(self) -> list[ContainerState]:
cmd, cwd=self.recipe.path.parent, env=os.environ | self.recipe.environment
).decode("utf-8")
return [ContainerState.model_validate_json(line) for line in res.splitlines()]

def get_container_logs(self, num_entries: int) -> list[str]:
if self.recipe is None:
return []

lines = []
for line in self.compose_do("logs", "--no-color", "-n", str(num_entries)).stdout:
lines.append(line.decode("utf-8").strip())
return lines

def _task_start(self) -> None:
for image_name in self.recipe.config.images:
Expand Down

0 comments on commit d9ee959

Please sign in to comment.