Przeglądaj źródła

document public types

Signed-off-by: Nicolas De Loof <[email protected]>
Nicolas De Loof 5 lat temu
rodzic
commit
9ec075baff
2 zmienionych plików z 8 dodań i 7 usunięć
  1. 2 2
      ecs/logs.go
  2. 6 5
      formatter/logs.go

+ 2 - 2
ecs/logs.go

@@ -18,8 +18,9 @@ package ecs
 
 import (
 	"context"
-	"github.com/docker/compose-cli/formatter"
 	"io"
+
+	"github.com/docker/compose-cli/formatter"
 )
 
 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)
 	return err
 }
-

+ 6 - 5
formatter/logs.go

@@ -24,7 +24,7 @@ import (
 	"strings"
 )
 
-
+// NewLogConsumer creates a new LogConsumer
 func NewLogConsumer(w io.Writer) LogConsumer {
 	return LogConsumer{
 		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) {
 	cf, ok := l.colors[service]
 	if !ok {
@@ -48,11 +49,12 @@ 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 {
 	return splitBuffer{
-		service: service,
+		service:   service,
 		container: container,
-		consumer: l,
+		consumer:  l,
 	}
 }
 
@@ -66,13 +68,13 @@ func (l *LogConsumer) computeWidth() {
 	l.width = width + 3
 }
 
+// LogConsumer consume logs from services and format them
 type LogConsumer struct {
 	colors map[string]colorFunc
 	width  int
 	writer io.Writer
 }
 
-
 type splitBuffer struct {
 	service   string
 	container string
@@ -88,4 +90,3 @@ func (s splitBuffer) Write(b []byte) (n int, err error) {
 	}
 	return len(b), nil
 }
-