Skip to content

Commit

Permalink
Use log instead of fmt in several places (#191)
Browse files Browse the repository at this point in the history
* Use log instead of fmt in several places, add a few new log lines for timing
  • Loading branch information
ehotinger authored Aug 6, 2018
1 parent c1b2f08 commit 68db728
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion baseimages/scanner/cmd/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ package cmd
import (
"context"
"encoding/json"
"fmt"
"os"

"fmt"
"io"
"time"

Expand Down
2 changes: 2 additions & 0 deletions builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ func NewBuilder(tm *taskmanager.TaskManager, debug bool, workspaceDir string) *B
// RunAllBuildSteps executes a pipeline.
func (b *Builder) RunAllBuildSteps(ctx context.Context, pipeline *graph.Pipeline) error {
if !b.taskManager.DryRun {
log.Printf("Setting up Docker configuration...")
if err := b.setupConfig(ctx); err != nil {
return err
}
log.Printf("Successfully set up Docker configuration")
if pipeline.UsingRegistryCreds() {
log.Printf("Logging in to registry: %s\n", pipeline.RegistryName)
if err := b.dockerLoginWithRetries(ctx, pipeline.RegistryName, pipeline.RegistryUsername, pipeline.RegistryPassword, 0); err != nil {
Expand Down
1 change: 1 addition & 0 deletions builder/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func (b *Builder) pushWithRetries(ctx context.Context, images []string) error {
time.Sleep(500 * time.Millisecond)
retry++
} else {
log.Printf("Successfully pushed image: %s\n", img)
break
}
}
Expand Down
2 changes: 1 addition & 1 deletion builder/setup_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (b *Builder) setupConfig(ctx context.Context) error {

var buf bytes.Buffer
if err := b.taskManager.Run(ctx, args, nil, &buf, &buf, ""); err != nil {
return errors.Wrap(err, fmt.Sprintf("failed to setup config: %s", buf.String()))
return errors.Wrap(err, fmt.Sprintf("failed to setup config, msg: %s", buf.String()))
}

return nil
Expand Down
3 changes: 2 additions & 1 deletion cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"errors"
"fmt"
"io"
"log"
"strings"
"time"

Expand Down Expand Up @@ -167,7 +168,7 @@ func (b *buildCmd) run(cmd *cobra.Command, args []string) error {
homeVolName = b.homeVol
}

fmt.Printf("Using %s as the home volume\n", homeVolName)
log.Printf("Using %s as the home volume\n", homeVolName)
builder := builder.NewBuilder(taskManager, debug, homeVolName)
defer builder.CleanAllBuildSteps(context.Background(), pipeline)
return builder.RunAllBuildSteps(ctx, pipeline)
Expand Down
3 changes: 2 additions & 1 deletion cmd/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"context"
"fmt"
"io"
"log"
"time"

"github.com/Azure/acr-builder/builder"
Expand Down Expand Up @@ -104,7 +105,7 @@ func (e *execCmd) run(cmd *cobra.Command, args []string) error {
homeVolName = e.homeVol
}

fmt.Printf("Using %s as the home volume\n", homeVolName)
log.Printf("Using %s as the home volume\n", homeVolName)
builder := builder.NewBuilder(taskManager, debug, homeVolName)
defer builder.CleanAllBuildSteps(context.Background(), pipeline)
return builder.RunAllBuildSteps(ctx, pipeline)
Expand Down
3 changes: 2 additions & 1 deletion templating/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"bytes"
"errors"
"fmt"
"log"
"sort"
"strings"
"text/template"
Expand Down Expand Up @@ -57,7 +58,7 @@ func (e *Engine) render(templates map[string]renderableTemplate) (rendered map[s
// If a template panics, recover the engine.
defer func() {
if r := recover(); r != nil {
fmt.Printf("Template rendering recovered. Value: %v\n", r)
log.Printf("Template rendering recovered. Value: %v\n", r)
}
}()

Expand Down

0 comments on commit 68db728

Please sign in to comment.