mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-03 00:25:59 +08:00
log
This commit is contained in:
+11
-11
@@ -3,23 +3,29 @@ package cmd
|
||||
import (
|
||||
"OpenIM/pkg/common/config"
|
||||
"OpenIM/pkg/common/constant"
|
||||
"OpenIM/pkg/common/log"
|
||||
"fmt"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
type RootCmd struct {
|
||||
Command cobra.Command
|
||||
Name string
|
||||
port int
|
||||
prometheusPort int
|
||||
}
|
||||
|
||||
func NewRootCmd() (rootCmd *RootCmd) {
|
||||
rootCmd = &RootCmd{}
|
||||
func NewRootCmd(name string) (rootCmd *RootCmd) {
|
||||
rootCmd = &RootCmd{Name: name}
|
||||
c := cobra.Command{
|
||||
Use: "start",
|
||||
Short: "Start the server",
|
||||
Long: `Start the server`,
|
||||
Short: fmt.Sprintf(`Start %s server`, name),
|
||||
Long: fmt.Sprintf(`Start %s server`, name),
|
||||
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
||||
return rootCmd.getConfFromCmdAndInit(cmd)
|
||||
if err := rootCmd.getConfFromCmdAndInit(cmd); err != nil {
|
||||
return err
|
||||
}
|
||||
return log.InitFromConfig(name)
|
||||
},
|
||||
}
|
||||
rootCmd.Command = c
|
||||
@@ -27,12 +33,6 @@ 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")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user