Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
virtcontainers: Fix structured logging in device/config package
Browse files Browse the repository at this point in the history
Call the `device/config` package `SetLogger()` function to ensure all its log
records contain all required structured logging fields.

Fixes: #2643

Signed-off-by: Julio Montes <[email protected]>
(cherry picked from commit d0dbd04)
  • Loading branch information
Julio Montes authored and amshinde committed Jun 3, 2020
1 parent 13887bf commit 673b471
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions virtcontainers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func SetLogger(ctx context.Context, logger *logrus.Entry) {
deviceApi.SetLogger(virtLog)
compatoci.SetLogger(virtLog)
store.SetLogger(virtLog)
deviceConfig.SetLogger(virtLog)
}

// CreateSandbox is the virtcontainers sandbox creation entry point.
Expand Down
7 changes: 7 additions & 0 deletions virtcontainers/device/config/pmem.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ var (
pmemLog = logrus.WithField("source", "virtcontainers/device/config")
)

// SetLogger sets up a logger for this pkg
func SetLogger(logger *logrus.Entry) {
fields := pmemLog.Data

pmemLog = logger.WithFields(fields)
}

// PmemDeviceInfo returns a DeviceInfo if a loop device
// is mounted on source, and the backing file of the loop device
// has the PFN signature.
Expand Down

0 comments on commit 673b471

Please sign in to comment.