mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-03 08:35:59 +08:00
log
This commit is contained in:
@@ -7,7 +7,7 @@ type ApiCmd struct {
|
||||
}
|
||||
|
||||
func NewApiCmd() *ApiCmd {
|
||||
return &ApiCmd{NewRootCmd()}
|
||||
return &ApiCmd{NewRootCmd("api")}
|
||||
}
|
||||
|
||||
func (a *ApiCmd) AddApi(f func(port int) error) {
|
||||
|
||||
@@ -7,7 +7,7 @@ type CronTaskCmd struct {
|
||||
}
|
||||
|
||||
func NewCronTaskCmd() *CronTaskCmd {
|
||||
return &CronTaskCmd{NewRootCmd()}
|
||||
return &CronTaskCmd{NewRootCmd("cronTask")}
|
||||
}
|
||||
|
||||
func (c *CronTaskCmd) addRunE(f func() error) {
|
||||
|
||||
@@ -12,7 +12,7 @@ type MsgGatewayCmd struct {
|
||||
}
|
||||
|
||||
func NewMsgGatewayCmd() MsgGatewayCmd {
|
||||
return MsgGatewayCmd{NewRootCmd()}
|
||||
return MsgGatewayCmd{NewRootCmd("msgGateway")}
|
||||
}
|
||||
|
||||
func (m *MsgGatewayCmd) AddWsPortFlag() {
|
||||
|
||||
@@ -10,7 +10,7 @@ type MsgTransferCmd struct {
|
||||
}
|
||||
|
||||
func NewMsgTransferCmd() MsgTransferCmd {
|
||||
return MsgTransferCmd{NewRootCmd()}
|
||||
return MsgTransferCmd{NewRootCmd("msgTransfer")}
|
||||
}
|
||||
|
||||
func (m *MsgTransferCmd) addRunE() {
|
||||
|
||||
@@ -18,7 +18,7 @@ type MsgUtilsCmd struct {
|
||||
}
|
||||
|
||||
func NewMsgUtilsCmd() MsgUtilsCmd {
|
||||
return MsgUtilsCmd{RootCmd: NewRootCmd()}
|
||||
return MsgUtilsCmd{RootCmd: NewRootCmd("msgUtils")}
|
||||
}
|
||||
|
||||
func (m *MsgUtilsCmd) AddUserIDFlag() {
|
||||
|
||||
+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")
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@ type RpcCmd struct {
|
||||
*RootCmd
|
||||
}
|
||||
|
||||
func NewRpcCmd() *RpcCmd {
|
||||
authCmd := &RpcCmd{NewRootCmd()}
|
||||
func NewRpcCmd(name string) *RpcCmd {
|
||||
authCmd := &RpcCmd{NewRootCmd(name)}
|
||||
return authCmd
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user