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

Commit

Permalink
logging: Add function to handle external loggers
Browse files Browse the repository at this point in the history
Created a new `setExternalLogger()` which sets (or resets) the logger
used by the external packages which allow a logger to be specified.

Signed-off-by: James O. D. Hunt <[email protected]>
  • Loading branch information
jodh-intel authored and Eric Ernst committed Aug 23, 2018
1 parent fdf1312 commit 371dc14
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,16 @@ func setupSignalHandler() {
}()
}

// setExternalLoggers registers the specified logger with the external
// packages which accept a logger to handle their own logging.
func setExternalLoggers(logger *logrus.Entry) {
// Set virtcontainers logger.
vci.SetLogger(logger)

// Set the OCI package logger.
oci.SetLogger(logger)
}

// beforeSubcommands is the function to perform preliminary checks
// before command-line parsing occurs.
func beforeSubcommands(context *cli.Context) error {
Expand Down Expand Up @@ -225,11 +235,7 @@ func beforeSubcommands(context *cli.Context) error {
return fmt.Errorf("unknown log-format %q", context.GlobalString("log-format"))
}

// Set virtcontainers logger.
vci.SetLogger(kataLog)

// Set the OCI package logger.
oci.SetLogger(kataLog)
setExternalLoggers(kataLog)

ignoreLogging := false

Expand Down

0 comments on commit 371dc14

Please sign in to comment.