Skip to content

Commit ffe93be

Browse files
committed
Add timestamps to migration command's reporting
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]>
1 parent 3f33f53 commit ffe93be

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

pkg/oc/admin/migrate/migrator.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"io"
66
"strings"
7+
"time"
78

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

53+
// TimeStampNow returns the current time in the same format as glog
54+
func TimeStampNow() string {
55+
return time.Now().Format("0102 15:04:05.000000")
56+
}
57+
5258
// NotChanged is a Reporter returned by operations that are guaranteed to be read-only
5359
var NotChanged = ReporterBool(false)
5460

@@ -397,9 +403,9 @@ func (t *migrateTracker) report(prefix string, info *resource.Info, err error) {
397403
ns = "-n " + ns
398404
}
399405
if err != nil {
400-
fmt.Fprintf(t.out, "%-10s %s %s/%s: %v\n", prefix, ns, info.Mapping.Resource, info.Name, err)
406+
fmt.Fprintf(t.out, "E%s %-10s %s %s/%s: %v\n", TimeStampNow(), prefix, ns, info.Mapping.Resource, info.Name, err)
401407
} else {
402-
fmt.Fprintf(t.out, "%-10s %s %s/%s\n", prefix, ns, info.Mapping.Resource, info.Name)
408+
fmt.Fprintf(t.out, "I%s %-10s %s %s/%s\n", TimeStampNow(), prefix, ns, info.Mapping.Resource, info.Name)
403409
}
404410
}
405411

0 commit comments

Comments
 (0)