mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-10 13:54:12 +00:00
store: Add SetLogger API
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 <james.o.hunt@intel.com>
This commit is contained in:
parent
e8a8e0db79
commit
f540a80354
@ -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.
|
||||
|
@ -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{
|
||||
|
Loading…
Reference in New Issue
Block a user