get log to manage `attach`

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof 2024-02-22 18:27:05 +01:00
parent a7224411b4
commit 58ec0e9fb6
No known key found for this signature in database
GPG Key ID: 9858809D6F8F6E7E
1 changed files with 10 additions and 0 deletions

View File

@ -75,6 +75,16 @@ func runLogs(ctx context.Context, dockerCli command.Cli, backend api.Service, op
if err != nil {
return err
}
// exclude services configured to ignore output (attach: false), until explicitly selected
if project != nil && len(services) == 0 {
for n, service := range project.Services {
if service.Attach == nil || *service.Attach {
services = append(services, n)
}
}
}
consumer := formatter.NewLogConsumer(ctx, dockerCli.Out(), dockerCli.Err(), !opts.noColor, !opts.noPrefix, false)
return backend.Logs(ctx, name, consumer, api.LogOptions{
Project: project,