Skip to content

Commit

Permalink
fix: use Error level by default
Browse files Browse the repository at this point in the history
Signed-off-by: ludo <[email protected]>
  • Loading branch information
spiarh committed Jan 10, 2024
1 parent 0ac7628 commit 1076941
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
21 changes: 6 additions & 15 deletions internal/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"io"
"log/slog"
"os"
"sync"
"time"

"github.com/docker/docker/api/types"
Expand Down Expand Up @@ -93,11 +92,11 @@ func (c Client) Run(ctx context.Context, conf Config) error {
defer cancel()

if err := c.client.ContainerStop(cctx, cont.ID, container.StopOptions{}); err != nil {
slog.Warn("failed to stop container", "id", cont.ID, "err", err)
slog.Error("failed to stop container", "id", cont.ID, "err", err)
}

if err := c.client.ContainerRemove(cctx, cont.ID, types.ContainerRemoveOptions{}); err != nil {
slog.Warn("failed to remove container", "id", cont.ID, "err", err)
slog.Error("failed to remove container", "id", cont.ID, "err", err)
}
}()

Expand All @@ -115,18 +114,10 @@ func (c Client) Run(ctx context.Context, conf Config) error {
return fmt.Errorf("failed to start container: %w", err)
}

var waitGroup sync.WaitGroup
waitGroup.Add(1)
go func() {
defer waitGroup.Done()

_, err := io.Copy(os.Stdout, hijack.Reader)
if err != nil {
slog.Warn("failed to copy container output", "err", err)
}
}()

waitGroup.Wait()
_, err = io.Copy(os.Stdout, hijack.Reader)
if err != nil {
return fmt.Errorf("failed to copy container output: %w", err)
}

return nil
}
Expand Down
2 changes: 1 addition & 1 deletion internal/logging/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
func Configure() {
handlerOptions := &slog.HandlerOptions{
AddSource: true,
Level: slog.LevelInfo,
Level: slog.LevelError,
}

logger := slog.New(slog.NewTextHandler(os.Stdout, handlerOptions))
Expand Down

0 comments on commit 1076941

Please sign in to comment.