diff --git a/cmd/containerd/command/main.go b/cmd/containerd/command/main.go index 80ef3761f..55e6393e7 100644 --- a/cmd/containerd/command/main.go +++ b/cmd/containerd/command/main.go @@ -48,6 +48,11 @@ high performance container runtime ` func init() { + logrus.SetFormatter(&logrus.TextFormatter{ + TimestampFormat: log.RFC3339NanoFixed, + FullTimestamp: true, + }) + // Discard grpc logs so that they don't mess with our stdio grpclog.SetLoggerV2(grpclog.NewLoggerV2(ioutil.Discard, ioutil.Discard, ioutil.Discard)) diff --git a/log/context.go b/log/context.go index f40603b17..3fab96b85 100644 --- a/log/context.go +++ b/log/context.go @@ -42,6 +42,10 @@ type ( // and is usually used to trace detailed behavior of the program. const TraceLevel = logrus.Level(uint32(logrus.DebugLevel + 1)) +// RFC3339NanoFixed is time.RFC3339Nano with nanoseconds padded using zeros to +// ensure the formatted time is always the same number of characters. +const RFC3339NanoFixed = "2006-01-02T15:04:05.000000000Z07:00" + // ParseLevel takes a string level and returns the Logrus log level constant. // It supports trace level. func ParseLevel(lvl string) (logrus.Level, error) {