@@ -34,25 +34,43 @@ func (s *composeService) Logs(ctx context.Context, projectName string, consumer
34
34
}
35
35
36
36
eg , ctx := errgroup .WithContext (ctx )
37
+ for _ , c := range containers {
38
+ c := c
39
+ eg .Go (func () error {
40
+ return s .logContainers (ctx , consumer , c , options )
41
+ })
42
+ }
43
+
37
44
if options .Follow {
38
45
printer := newLogPrinter (consumer )
46
+ eg .Go (func () error {
47
+ for _ , c := range containers {
48
+ printer .HandleEvent (api.ContainerEvent {
49
+ Type : api .ContainerEventAttach ,
50
+ Container : getContainerNameWithoutProject (c ),
51
+ Service : c .Labels [api .ServiceLabel ],
52
+ })
53
+ }
54
+ return nil
55
+ })
56
+
39
57
eg .Go (func () error {
40
58
return s .watchContainers (ctx , projectName , options .Services , printer .HandleEvent , containers , func (c types.Container ) error {
59
+ printer .HandleEvent (api.ContainerEvent {
60
+ Type : api .ContainerEventAttach ,
61
+ Container : getContainerNameWithoutProject (c ),
62
+ Service : c .Labels [api .ServiceLabel ],
63
+ })
41
64
return s .logContainers (ctx , consumer , c , options )
42
65
})
43
66
})
67
+
44
68
eg .Go (func () error {
45
69
_ , err := printer .Run (ctx , false , "" , nil )
46
70
return err
47
71
})
48
72
}
49
73
50
- for _ , c := range containers {
51
- c := c
52
- eg .Go (func () error {
53
- return s .logContainers (ctx , consumer , c , options )
54
- })
55
- }
56
74
return eg .Wait ()
57
75
}
58
76
0 commit comments