This commit is contained in:
wangchuxiao
2023-03-10 18:37:36 +08:00
parent d545a7f753
commit 662254f30f
8 changed files with 341 additions and 77 deletions
+17
View File
@@ -3,6 +3,7 @@ package cmd
import (
"OpenIM/pkg/common/config"
"OpenIM/pkg/common/constant"
log "OpenIM/pkg/common/logger"
"github.com/spf13/cobra"
)
@@ -19,6 +20,16 @@ func NewRootCmd() (rootCmd *RootCmd) {
Short: "Start the server",
Long: `Start the server`,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
log.InitFromConfig(log.Config{
JSON: true,
Level: "",
Sample: false,
SampleInitial: 0,
SampleInterval: 0,
ItemSampleSeconds: 0,
ItemSampleInitial: 0,
ItemSampleInterval: 0,
}, "newlog")
return rootCmd.getConfFromCmdAndInit(cmd)
},
}
@@ -27,6 +38,12 @@ func NewRootCmd() (rootCmd *RootCmd) {
return rootCmd
}
func (r *RootCmd) SetDesc(use, short, long string) {
r.Command.Use = use
r.Command.Short = short
r.Command.Long = long
}
func (r *RootCmd) addConfFlag() {
r.Command.Flags().StringP(constant.FlagConf, "c", "", "Path to config file folder")
}