Skip to content

Commit

Permalink
Merge pull request microsoft#1898 from dmcgowan/update-containerd-log…
Browse files Browse the repository at this point in the history
…-dependency

Update containerd log dependency
  • Loading branch information
kevpar authored Sep 29, 2023
2 parents 1a896a2 + a489b50 commit 1f4a52d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 5 additions & 2 deletions log/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ import (
"reflect"
"time"

"github.com/containerd/containerd/log"
"github.com/sirupsen/logrus"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"
)

const TimeFormat = log.RFC3339NanoFixed
// TimeFormat is [time.RFC3339Nano] with nanoseconds padded using
// zeros to ensure the formatted time is always the same number of
// characters.
// Based on RFC3339NanoFixed from github.com/containerd/log
const TimeFormat = "2006-01-02T15:04:05.000000000Z07:00"

func FormatTime(t time.Time) string {
return t.Format(TimeFormat)
Expand Down
5 changes: 2 additions & 3 deletions log/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"time"

"github.com/Microsoft/hcsshim/internal/logfields"
"github.com/containerd/containerd/log"
"github.com/sirupsen/logrus"
"go.opencensus.io/trace"
)
Expand All @@ -30,7 +29,7 @@ type Hook struct {
// An empty string disables formatting.
// When disabled, the fall back will the JSON encoding, if enabled.
//
// Default is [github.com/containerd/containerd/log.RFC3339NanoFixed].
// Default is [TimeFormat].
TimeFormat string

// Duration format converts a [time.Duration] fields to an appropriate encoding.
Expand All @@ -49,7 +48,7 @@ var _ logrus.Hook = &Hook{}

func NewHook() *Hook {
return &Hook{
TimeFormat: log.RFC3339NanoFixed,
TimeFormat: TimeFormat,
DurationFormat: DurationFormatString,
AddSpanContext: true,
}
Expand Down

0 comments on commit 1f4a52d

Please sign in to comment.