MCPcopy
hub / github.com/docker/compose / doLogContainer

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
125func (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}

Callers 3

LogsMethod · 0.95
logContainerMethod · 0.95
UpMethod · 0.95

Calls 6

apiClientMethod · 0.95
GetWriterFunction · 0.92
CloseMethod · 0.65
LogMethod · 0.65
CopyMethod · 0.65
ContainerLogsMethod · 0.45

Tested by

no test coverage detected