Method
doLogContainer
pkg/compose/logs.go:125–149
· pkg/compose/logs.go::composeService.doLogContainer
(ctx context.Context, consumer api.LogConsumer, name string, ctr container.InspectResponse, options api.LogOptions)
Source from the content-addressed store, hash-verified
| 123 | } |
| 124 | |
| 125 | func (s *composeService) doLogContainer(ctx context.Context, consumer api.LogConsumer, name string, ctr container.InspectResponse, options api.LogOptions) error { |
| 126 | r, err := s.apiClient().ContainerLogs(ctx, ctr.ID, client.ContainerLogsOptions{ |
| 127 | ShowStdout: true, |
| 128 | ShowStderr: true, |
| 129 | Follow: options.Follow, |
| 130 | Since: options.Since, |
| 131 | Until: options.Until, |
| 132 | Tail: options.Tail, |
| 133 | Timestamps: options.Timestamps, |
| 134 | }) |
| 135 | if err != nil { |
| 136 | return err |
| 137 | } |
| 138 | defer r.Close() //nolint:errcheck |
| 139 | |
| 140 | w := utils.GetWriter(func(line string) { |
| 141 | consumer.Log(name, line) |
| 142 | }) |
| 143 | if ctr.Config.Tty { |
| 144 | _, err = io.Copy(w, r) |
| 145 | } else { |
| 146 | _, err = stdcopy.StdCopy(w, w, r) |
| 147 | } |
| 148 | return err |
| 149 | } |
Tested by
no test coverage detected