diff --git a/cmd/sealctl/boot/boot.go b/cmd/sealctl/boot/boot.go index 882cea338..bab2d85e9 100644 --- a/cmd/sealctl/boot/boot.go +++ b/cmd/sealctl/boot/boot.go @@ -25,10 +25,11 @@ import ( var Debug bool var ConfigDir string +var ShowPatch bool // initConfig reads in config file and ENV variables if set. func initConfig() { - logger.Cfg(Debug, ConfigDir, "sealctl") + logger.Cfg(Debug, ConfigDir, "sealctl", ShowPatch) } func InitRootDirectory(rootDirs []string) error { diff --git a/cmd/sealctl/cmd/root.go b/cmd/sealctl/cmd/root.go index 364088f66..edfeab638 100644 --- a/cmd/sealctl/cmd/root.go +++ b/cmd/sealctl/cmd/root.go @@ -46,4 +46,5 @@ func init() { cobra.OnInitialize(boot.OnBootOnDie) rootCmd.PersistentFlags().StringVar(&boot.ConfigDir, "config", contants.DefaultConfigPath, "config dir (default is $HOME/.sealos)") rootCmd.PersistentFlags().BoolVar(&boot.Debug, "debug", false, "enable debug logger") + rootCmd.PersistentFlags().BoolVar(&boot.ShowPatch, "path", false, "enable show code path") } diff --git a/cmd/sealos/boot/boot.go b/cmd/sealos/boot/boot.go index cbe084705..e35e860f0 100644 --- a/cmd/sealos/boot/boot.go +++ b/cmd/sealos/boot/boot.go @@ -26,13 +26,13 @@ import ( var Debug bool var ConfigDir string var ConfigFile string - +var ShowPatch bool var ConfigFilePath string // initConfig reads in config file and ENV variables if set. func initConfig() { ConfigFilePath = ConfigDir + ConfigFile - logger.Cfg(Debug, ConfigDir, "sealos") + logger.Cfg(Debug, ConfigDir, "sealos", ShowPatch) } func initRootDirectory() error { diff --git a/cmd/sealos/cmd/root.go b/cmd/sealos/cmd/root.go index 397ee9b78..0d4256d10 100644 --- a/cmd/sealos/cmd/root.go +++ b/cmd/sealos/cmd/root.go @@ -48,4 +48,5 @@ func init() { rootCmd.PersistentFlags().StringVar(&boot.ConfigFile, "config-file", contants.DefaultConfigFile, "config file (default is /config.yaml )") rootCmd.PersistentFlags().BoolVar(&boot.Debug, "debug", false, "enable debug logger") + rootCmd.PersistentFlags().BoolVar(&boot.ShowPatch, "path", false, "enable show code path") } diff --git a/pkg/utils/logger/log.go b/pkg/utils/logger/log.go index b3d441c9a..c96cd2475 100755 --- a/pkg/utils/logger/log.go +++ b/pkg/utils/logger/log.go @@ -149,7 +149,7 @@ func init() { defaultLogger = NewLogger(3) } -func Cfg(debugMod bool, logDir, name string) { +func Cfg(debugMod bool, logDir, name string, showPath bool) { debugMode = debugMod logLev := 5 if debugMod { @@ -177,7 +177,7 @@ func Cfg(debugMod bool, logDir, name string) { logLev, logDir, name, time.Now().Format("2006-01-02"), )) - SetLogPath(true) + SetLogPath(showPath) } func (localLog *LocalLogger) SetLogger(adapterName string, configs ...string) {