use --debug to replace --silent (#37)
* add --silent to service command * ? * use --debug to toggle the logging
This commit is contained in:
parent
3bf3f97767
commit
fda3a52533
@ -80,9 +80,9 @@ func editAgentConfig(cmd *cobra.Command, args []string) {
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "slient",
|
||||
Name: "debug",
|
||||
Prompt: &survey.Confirm{
|
||||
Message: "是否禁用日志输出?",
|
||||
Message: "是否开启调试模式?",
|
||||
Default: false,
|
||||
},
|
||||
},
|
||||
@ -94,7 +94,7 @@ func editAgentConfig(cmd *cobra.Command, args []string) {
|
||||
DNS string
|
||||
GPU bool
|
||||
Temperature bool
|
||||
Slient bool
|
||||
Debug bool
|
||||
}{}
|
||||
|
||||
err = survey.Ask(qs, &answers, survey.WithValidator(survey.Required))
|
||||
@ -134,7 +134,7 @@ func editAgentConfig(cmd *cobra.Command, args []string) {
|
||||
|
||||
agentConfig.GPU = answers.GPU
|
||||
agentConfig.Temperature = answers.Temperature
|
||||
agentConfig.Slient = answers.Slient
|
||||
agentConfig.Debug = answers.Debug
|
||||
|
||||
if err = agentConfig.Save(); err != nil {
|
||||
panic(err)
|
||||
|
@ -45,7 +45,6 @@ type AgentCliParam struct {
|
||||
DisableAutoUpdate bool // 关闭自动更新
|
||||
DisableForceUpdate bool // 关闭强制更新
|
||||
DisableCommandExecute bool // 关闭命令执行
|
||||
Debug bool // debug模式
|
||||
Server string // 服务器地址
|
||||
ClientSecret string // 客户端密钥
|
||||
ReportDelay int // 报告间隔
|
||||
@ -53,7 +52,7 @@ type AgentCliParam struct {
|
||||
InsecureTLS bool // 是否禁用证书检查
|
||||
Version bool // 当前版本号
|
||||
IPReportPeriod uint32 // 上报IP间隔
|
||||
UseIPv6CountryCode bool // 默认优先展示IPv6旗帜
|
||||
UseIPv6CountryCode bool // 默认优先展示IPv6旗帜
|
||||
}
|
||||
|
||||
var (
|
||||
@ -143,7 +142,7 @@ func init() {
|
||||
agentCmd.PersistentFlags().StringVarP(&agentCliParam.ClientSecret, "password", "p", "", "Agent连接Secret")
|
||||
agentCmd.PersistentFlags().BoolVar(&agentCliParam.TLS, "tls", false, "启用SSL/TLS加密")
|
||||
agentCmd.PersistentFlags().BoolVarP(&agentCliParam.InsecureTLS, "insecure", "k", false, "禁用证书检查")
|
||||
agentCmd.PersistentFlags().BoolVarP(&agentCliParam.Debug, "debug", "d", false, "开启调试信息")
|
||||
agentCmd.PersistentFlags().BoolVarP(&agentConfig.Debug, "debug", "d", false, "开启调试信息")
|
||||
agentCmd.PersistentFlags().IntVar(&agentCliParam.ReportDelay, "report-delay", 1, "系统状态上报间隔")
|
||||
agentCmd.PersistentFlags().BoolVar(&agentCliParam.SkipConnectionCount, "skip-conn", false, "不监控连接数")
|
||||
agentCmd.PersistentFlags().BoolVar(&agentCliParam.SkipProcsCount, "skip-procs", false, "不监控进程数")
|
||||
@ -154,7 +153,6 @@ func init() {
|
||||
agentCmd.PersistentFlags().BoolVar(&agentConfig.GPU, "gpu", false, "启用GPU监控")
|
||||
agentCmd.PersistentFlags().BoolVar(&agentConfig.Temperature, "temperature", false, "启用温度监控")
|
||||
agentCmd.PersistentFlags().Uint32VarP(&agentCliParam.IPReportPeriod, "ip-report-period", "u", 30*60, "本地IP更新间隔, 上报频率依旧取决于report-delay的值")
|
||||
agentCmd.Flags().BoolVarP(&agentConfig.Slient, "slient", "q", false, "关闭日志输出")
|
||||
agentCmd.Flags().BoolVarP(&agentCliParam.Version, "version", "v", false, "查看当前版本号")
|
||||
|
||||
agentConfig.Read(filepath.Dir(ex) + "/config.yml")
|
||||
@ -223,7 +221,7 @@ func run() {
|
||||
// 上报服务器信息
|
||||
go reportState()
|
||||
// 更新IP信息
|
||||
go monitor.UpdateIP(agentConfig.Slient, agentCliParam.UseIPv6CountryCode, agentCliParam.IPReportPeriod)
|
||||
go monitor.UpdateIP(agentConfig.Debug, agentCliParam.UseIPv6CountryCode, agentCliParam.IPReportPeriod)
|
||||
|
||||
// 定时检查更新
|
||||
if _, err := semver.Parse(version); err == nil && !agentCliParam.DisableAutoUpdate {
|
||||
@ -712,9 +710,7 @@ func handleTerminalTask(task *pb.Task) {
|
||||
}
|
||||
|
||||
func println(v ...interface{}) {
|
||||
if agentCliParam.Debug {
|
||||
util.Println(agentConfig.Slient, v...)
|
||||
}
|
||||
util.Println(agentConfig.Debug, v...)
|
||||
}
|
||||
|
||||
func generateQueue(start int, size int) []int {
|
||||
|
@ -79,7 +79,7 @@ func serviceActions(cmd *cobra.Command, args []string) {
|
||||
{agentCliParam.Server != "localhost:5555", "-s", agentCliParam.Server},
|
||||
{agentCliParam.ClientSecret != "", "-p", agentCliParam.ClientSecret},
|
||||
{agentCliParam.TLS, "--tls", ""},
|
||||
{agentCliParam.Debug, "-d", ""},
|
||||
{agentConfig.Debug, "-d", ""},
|
||||
{agentCliParam.ReportDelay != 1, "--report-delay", fmt.Sprint(agentCliParam.ReportDelay)},
|
||||
{agentCliParam.SkipConnectionCount, "--skip-conn", ""},
|
||||
{agentCliParam.SkipProcsCount, "--skip-procs", ""},
|
||||
|
@ -13,7 +13,7 @@ type AgentConfig struct {
|
||||
DNS []string
|
||||
GPU bool
|
||||
Temperature bool
|
||||
Slient bool
|
||||
Debug bool
|
||||
v *viper.Viper
|
||||
}
|
||||
|
||||
|
@ -413,5 +413,5 @@ func atomicStoreFloat64(x *uint64, v float64) {
|
||||
}
|
||||
|
||||
func println(v ...interface{}) {
|
||||
util.Println(agentConfig.Slient, v...)
|
||||
util.Println(agentConfig.Debug, v...)
|
||||
}
|
||||
|
@ -19,8 +19,8 @@ func IsWindows() bool {
|
||||
return os.PathSeparator == '\\' && os.PathListSeparator == ';'
|
||||
}
|
||||
|
||||
func Println(disabled bool, v ...interface{}) {
|
||||
if !disabled {
|
||||
func Println(enabled bool, v ...interface{}) {
|
||||
if enabled {
|
||||
if runtime.GOOS != "darwin" {
|
||||
Logger.Infof("NEZHA@%s>> %v", time.Now().Format("2006-01-02 15:04:05"), fmt.Sprint(v...))
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user