refactor(master): fix logger #645 (#857)

This commit is contained in:
cuisongliu
2022-02-16 12:10:08 +08:00
committed by GitHub
parent 79314a29c7
commit 8dae8a94a8
5 changed files with 8 additions and 5 deletions
+2 -1
View File
@@ -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 {
+1
View File
@@ -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")
}
+2 -2
View File
@@ -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 {
+1
View File
@@ -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")
}
+2 -2
View File
@@ -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) {