diff --git a/internal/app/wwctl/container/exec/main.go b/internal/app/wwctl/container/exec/main.go index 722ba479..58fc60b8 100644 --- a/internal/app/wwctl/container/exec/main.go +++ b/internal/app/wwctl/container/exec/main.go @@ -17,9 +17,13 @@ import ( "github.com/spf13/cobra" ) +/* +fork off a process with a new PID space +*/ func runContainedCmd(args []string) error { + logStr := fmt.Sprint(wwlog.GetLogLevel()) wwlog.Verbose("Running contained command: %s", args[1:]) - c := exec.Command("/proc/self/exe", append([]string{"container", "exec", "__child"}, args...)...) + c := exec.Command("/proc/self/exe", append([]string{"--loglevel", logStr, "container", "exec", "__child"}, args...)...) c.SysProcAttr = &syscall.SysProcAttr{ Cloneflags: syscall.CLONE_NEWUTS | syscall.CLONE_NEWPID | syscall.CLONE_NEWNS, diff --git a/internal/app/wwctl/root.go b/internal/app/wwctl/root.go index 81fe2a26..cc8927d6 100644 --- a/internal/app/wwctl/root.go +++ b/internal/app/wwctl/root.go @@ -31,12 +31,14 @@ var ( } verboseArg bool DebugFlag bool + LogLevel int ) func init() { rootCmd.PersistentFlags().BoolVarP(&verboseArg, "verbose", "v", false, "Run with increased verbosity.") rootCmd.PersistentFlags().BoolVarP(&DebugFlag, "debug", "d", false, "Run with debugging messages enabled.") - + rootCmd.PersistentFlags().IntVar(&LogLevel, "loglevel", wwlog.INFO, "Set log level to given string") + _ = rootCmd.PersistentFlags().MarkHidden("loglevel") rootCmd.SetUsageTemplate(help.UsageTemplate) rootCmd.SetHelpTemplate(help.HelpTemplate) @@ -65,6 +67,9 @@ func rootPersistentPreRunE(cmd *cobra.Command, args []string) error { } else { wwlog.SetLogLevel(wwlog.INFO) } + if LogLevel != wwlog.INFO { + wwlog.SetLogLevel(LogLevel) + } return nil }