Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions cmd/image-builder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"strings"
"syscall"

"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/pflag"

Expand Down Expand Up @@ -646,14 +647,23 @@ operating systems like Fedora, CentOS and RHEL with easy customizations support.

rootCmd.AddCommand(describeImgCmd)

verbose, err := rootCmd.PersistentFlags().GetBool("verbose")
if err != nil {
return err
}
if verbose {
olog.SetDefault(log.New(os.Stderr, "", 0))
// XXX: add once images has olog support
//images_log.SetDefault(log.New(os.Stderr, "", 0))
// Flags are not parsed yet, so we need to use this hook for enabling verbose logging for all commands
rootCmd.PersistentPreRunE = func(cmd *cobra.Command, args []string) error {
verbose, err := cmd.Flags().GetBool("verbose")
if err != nil {
return err
}
if verbose {
olog.SetDefault(log.New(os.Stderr, "", 0))
olog.Print("verbose logging enabled")
// osbuild/images still partially uses logrus, so enable it here as well
logrus.SetLevel(logrus.DebugLevel)
logrus.SetOutput(os.Stderr)
logrus.Debug("legacy logrus logging enabled")
// XXX: add once images has olog support, and drop logrus
//images_log.SetDefault(log.New(os.Stderr, "", 0))
}
return nil
}

return rootCmd.Execute()
Expand Down
Loading