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

Commit

Permalink
store: Add SetLogger API
Browse files Browse the repository at this point in the history
Add a `store.SetLogger()` API to allow the store package to log with the
standard set of fields (as expected by the log parser [1].

Fixes #1297.

---

[1] - https://github.com/kata-containers/tests/tree/master/cmd/log-parser#logfile-requirements

Signed-off-by: James O. D. Hunt <[email protected]>
  • Loading branch information
jodh-intel committed Feb 28, 2019
1 parent e8a8e0d commit f540a80
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 @@ -48,6 +48,7 @@ func SetLogger(ctx context.Context, logger *logrus.Entry) {
virtLog = logger.WithFields(fields)

deviceApi.SetLogger(virtLog)
store.SetLogger(virtLog)
}

// CreateSandbox is the virtcontainers sandbox creation entry point.
Expand Down
7 changes: 7 additions & 0 deletions virtcontainers/store/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,13 @@ func DeleteAll() {

var storeLog = logrus.WithField("source", "virtcontainers/store")

// SetLogger sets the custom logger to be used by this package. If not called,
// the package will create its own logger.
func SetLogger(logger *logrus.Entry) {
fields := storeLog.Data
storeLog = logger.WithFields(fields)
}

// Logger returns a logrus logger appropriate for logging Store messages
func (s *Store) Logger() *logrus.Entry {
return storeLog.WithFields(logrus.Fields{
Expand Down

0 comments on commit f540a80

Please sign in to comment.