document public types

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof 2020-11-17 11:57:38 +01:00
parent 6346db1d6f
commit 9ec075baff
No known key found for this signature in database
GPG Key ID: 9858809D6F8F6E7E
2 changed files with 8 additions and 7 deletions

View File

@ -18,8 +18,9 @@ package ecs
import ( import (
"context" "context"
"github.com/docker/compose-cli/formatter"
"io" "io"
"github.com/docker/compose-cli/formatter"
) )
func (b *ecsAPIService) Logs(ctx context.Context, project string, w io.Writer) error { func (b *ecsAPIService) Logs(ctx context.Context, project string, w io.Writer) error {
@ -27,4 +28,3 @@ func (b *ecsAPIService) Logs(ctx context.Context, project string, w io.Writer) e
err := b.aws.GetLogs(ctx, project, consumer.Log) err := b.aws.GetLogs(ctx, project, consumer.Log)
return err return err
} }

View File

@ -24,7 +24,7 @@ import (
"strings" "strings"
) )
// NewLogConsumer creates a new LogConsumer
func NewLogConsumer(w io.Writer) LogConsumer { func NewLogConsumer(w io.Writer) LogConsumer {
return LogConsumer{ return LogConsumer{
colors: map[string]colorFunc{}, colors: map[string]colorFunc{},
@ -33,6 +33,7 @@ func NewLogConsumer(w io.Writer) LogConsumer {
} }
} }
// Log formats a log message as received from service/container
func (l *LogConsumer) Log(service, container, message string) { func (l *LogConsumer) Log(service, container, message string) {
cf, ok := l.colors[service] cf, ok := l.colors[service]
if !ok { if !ok {
@ -48,6 +49,7 @@ func (l *LogConsumer) Log(service, container, message string) {
} }
} }
// GetWriter creates a io.Writer that will actually split by line and format by LogConsumer
func (l *LogConsumer) GetWriter(service, container string) io.Writer { func (l *LogConsumer) GetWriter(service, container string) io.Writer {
return splitBuffer{ return splitBuffer{
service: service, service: service,
@ -66,13 +68,13 @@ func (l *LogConsumer) computeWidth() {
l.width = width + 3 l.width = width + 3
} }
// LogConsumer consume logs from services and format them
type LogConsumer struct { type LogConsumer struct {
colors map[string]colorFunc colors map[string]colorFunc
width int width int
writer io.Writer writer io.Writer
} }
type splitBuffer struct { type splitBuffer struct {
service string service string
container string container string
@ -88,4 +90,3 @@ func (s splitBuffer) Write(b []byte) (n int, err error) {
} }
return len(b), nil return len(b), nil
} }