Skip to content

Commit

Permalink
Add timestamps to migration command's reporting
Browse files Browse the repository at this point in the history
This change adds glog style timestamps to the reporting output of
the migration tracker.  This will aid in debugging migration errors
by making it easier to correlate client errors with master logs.

Signed-off-by: Monis Khan <[email protected]>
  • Loading branch information
enj committed Oct 28, 2017
1 parent 3f33f53 commit ffe93be
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pkg/oc/admin/migrate/migrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"io"
"strings"
"time"

"github.com/golang/glog"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -49,6 +50,11 @@ func AlwaysRequiresMigration(_ *resource.Info) (Reporter, error) {
return ReporterBool(true), nil
}

// TimeStampNow returns the current time in the same format as glog
func TimeStampNow() string {
return time.Now().Format("0102 15:04:05.000000")
}

// NotChanged is a Reporter returned by operations that are guaranteed to be read-only
var NotChanged = ReporterBool(false)

Expand Down Expand Up @@ -397,9 +403,9 @@ func (t *migrateTracker) report(prefix string, info *resource.Info, err error) {
ns = "-n " + ns
}
if err != nil {
fmt.Fprintf(t.out, "%-10s %s %s/%s: %v\n", prefix, ns, info.Mapping.Resource, info.Name, err)
fmt.Fprintf(t.out, "E%s %-10s %s %s/%s: %v\n", TimeStampNow(), prefix, ns, info.Mapping.Resource, info.Name, err)
} else {
fmt.Fprintf(t.out, "%-10s %s %s/%s\n", prefix, ns, info.Mapping.Resource, info.Name)
fmt.Fprintf(t.out, "I%s %-10s %s %s/%s\n", TimeStampNow(), prefix, ns, info.Mapping.Resource, info.Name)
}
}

Expand Down

0 comments on commit ffe93be

Please sign in to comment.