mirror of
https://github.com/docker/compose.git
synced 2025-05-10 17:40:15 +02:00
27 lines
464 B
Go
27 lines
464 B
Go
package streams
|
|
|
|
import (
|
|
"io"
|
|
|
|
"google.golang.org/grpc"
|
|
|
|
containersv1 "github.com/docker/api/protos/containers/v1"
|
|
)
|
|
|
|
// Log implements an io.Writer that proxies logs over a gRPC stream
|
|
type Log struct {
|
|
Stream grpc.ServerStream
|
|
}
|
|
|
|
func newStreamWriter(stream grpc.ServerStream) io.Writer {
|
|
return &Log{
|
|
Stream: stream,
|
|
}
|
|
}
|
|
|
|
func (w *Log) Write(p []byte) (n int, err error) {
|
|
return len(p), w.Stream.SendMsg(&containersv1.LogsResponse{
|
|
Value: p,
|
|
})
|
|
}
|