-
Notifications
You must be signed in to change notification settings - Fork 533
feat(podman-logs): improve logs formatting and behavior like docker-c… #1269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
await asyncio.gather(*tasks, return_exceptions=True) | ||
raise | ||
else: | ||
podman_args = [] |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
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.
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? |
3a39657
to
f76bda4
Compare
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.