simplify logger time and avoid possible crashes (#13986)

time.Format() is not necessary prematurely for JSON
marshalling, since JSON marshalling indeed defaults
to RFC3339Nano.

This also ensures the 'time' is remembered until its
logged and it is the same time when the 'caller'
invoked 'log' functions.
This commit is contained in:
Harshavardhana
2021-12-23 15:33:54 -08:00
committed by GitHub
parent 5a96cbbeaa
commit 9ad6012782
6 changed files with 38 additions and 31 deletions

View File

@@ -31,10 +31,10 @@ const Version = "1"
// Entry - audit entry logs.
type Entry struct {
Version string `json:"version"`
DeploymentID string `json:"deploymentid,omitempty"`
Time string `json:"time"`
Trigger string `json:"trigger"`
Version string `json:"version"`
DeploymentID string `json:"deploymentid,omitempty"`
Time time.Time `json:"time"`
Trigger string `json:"trigger"`
API struct {
Name string `json:"name,omitempty"`
Bucket string `json:"bucket,omitempty"`
@@ -61,7 +61,7 @@ func NewEntry(deploymentID string) Entry {
return Entry{
Version: Version,
DeploymentID: deploymentID,
Time: time.Now().UTC().Format(time.RFC3339Nano),
Time: time.Now().UTC(),
}
}