Skip to content

Conversation

arkhan
Copy link

@arkhan arkhan commented Jul 9, 2025

This update improves the logging output for containers, making it more
consistent with docker-compose behavior.

By default, the logs now include the project name along with the service name,
making it easier to identify containers in multi-service setups. If the -n or
--name flag is provided, the project name is omitted from the logs prefix.

Additionally, if a container_name is explicitly defined in the configuration,
it will always be shown by default instead of the generated name.

This enhancement helps users track logs more easily when managing multiple
containers.

BREAKING CHANGE: Logs output format may differ from previous versions.

@arkhan arkhan closed this Jul 9, 2025
@arkhan arkhan reopened this Jul 9, 2025
await asyncio.gather(*tasks, return_exceptions=True)
raise
else:
podman_args = []
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like duplicate code now.

service_name = cnt["_service"]
container_name = cnt["name"]

if getattr(args, 'names', False):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate code

display_name = container_name

space_suffix = " " * (max_service_length + 1 - len(display_name))
log_formatter = "{}{}{}|\x1b[0m".format(color, display_name, space_suffix)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate code, including space_suffix.

podman_args.append(target)

task = asyncio.create_task(
compose.podman.run([], "logs", podman_args, log_formatter=log_formatter),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Future improvement (not this PR): run only single podman logs command and improve the formatter to be able to apply different formatting depending on container ID that podman logs emits on every line.

@p12tic
Copy link
Collaborator

p12tic commented Jul 12, 2025

Thanks for the pull request, the basic idea looks great, I just had several nits regarding code style. Could you please also add a newsfragment and an integration test?

@arkhan arkhan force-pushed the feat/improve-logs-handling branch from 3a39657 to f76bda4 Compare July 31, 2025 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants