diff --git a/broadcast.go b/broadcast.go index 57c43a0..eb58849 100644 --- a/broadcast.go +++ b/broadcast.go @@ -7,7 +7,8 @@ import ( "time" "github.com/glycerine/rbuf" - "github.com/qiniu/log" + + log "github.com/sirupsen/logrus" ) // The new broadcast diff --git a/distributed.go b/distributed.go index bbb32fd..332d985 100644 --- a/distributed.go +++ b/distributed.go @@ -18,7 +18,8 @@ import ( "github.com/bluele/gcache" "github.com/gorilla/mux" "github.com/gorilla/websocket" - "github.com/qiniu/log" + + log "github.com/sirupsen/logrus" ) type Cluster struct { @@ -106,7 +107,7 @@ func (cluster *Cluster) cmdQueryDistributedPrograms(w http.ResponseWriter, r *ht w.Header().Set("Content-Type", "application/json") slaves := []string{} - for _, v := range cluster.slaves.GetALL() { + for _, v := range cluster.slaves.GetALL(true) { if slave, ok := v.(string); ok { slaves = append(slaves, slave) } @@ -119,7 +120,7 @@ func (cluster *Cluster) cmdQueryDistributedPrograms(w http.ResponseWriter, r *ht if body, err := cluster.requestSlave(reqUrl, http.MethodGet, nil); err == nil { jsonOut += fmt.Sprintf("\"%s\":%s", slave, body) } - if idx < cluster.slaves.Len()-1 { + if idx < cluster.slaves.Len(true)-1 { jsonOut += "," } idx += 1 diff --git a/fsm.go b/fsm.go index 1aa00e9..b83875e 100644 --- a/fsm.go +++ b/fsm.go @@ -31,11 +31,12 @@ import ( "github.com/axgle/pinyin" "github.com/kennygrant/sanitize" - "github.com/lunny/dingtalk_webhook" + dingtalk "github.com/lunny/dingtalk_webhook" "github.com/natefinch/lumberjack" - "github.com/qiniu/log" "github.com/soopsio/gosuv/pushover" "github.com/soopsio/kexec" + + log "github.com/sirupsen/logrus" ) type FSMState string diff --git a/gosuv.go b/gosuv.go index 7c477b3..03e305e 100644 --- a/gosuv.go +++ b/gosuv.go @@ -12,8 +12,9 @@ import ( "strings" "github.com/imroc/req" - "github.com/qiniu/log" "github.com/urfave/cli" + + log "github.com/sirupsen/logrus" ) const appID = "app_8Gji4eEAdDx" @@ -113,6 +114,13 @@ func checkServerStatus() error { func main() { var defaultConfigPath = filepath.Join(defaultGosuvDir, "conf/config.yml") + // 设置日志格式 + log.SetFormatter(&log.TextFormatter{}) + // 设置日志输出位置 + log.SetOutput(os.Stdout) + // 设置日志输出级别(要输出Debug信息可改为 DebugLevel 或 TraceLevel) + log.SetLevel(log.InfoLevel) + app := cli.NewApp() app.Name = "gosuv" app.Version = version diff --git a/merge_write.go b/merge_write.go index 47387b6..04e9a1b 100644 --- a/merge_write.go +++ b/merge_write.go @@ -6,7 +6,7 @@ import ( "io" "time" - log "github.com/qiniu/log" + log "github.com/sirupsen/logrus" ) type Bool struct { diff --git a/utils.go b/utils.go index 84f0c42..9d02960 100644 --- a/utils.go +++ b/utils.go @@ -8,7 +8,7 @@ import ( "strings" "time" - "github.com/qiniu/log" + log "github.com/sirupsen/logrus" ) var ErrGoTimeout = errors.New("GoTimeoutFunc") diff --git a/web.go b/web.go index d178e81..9a144fa 100644 --- a/web.go +++ b/web.go @@ -21,10 +21,11 @@ import ( "github.com/go-yaml/yaml" "github.com/gorilla/mux" "github.com/gorilla/websocket" - "github.com/qiniu/log" _ "github.com/shurcooL/vfsgen" "github.com/soopsio/gosuv/gops" "github.com/soopsio/kexec" + + log "github.com/sirupsen/logrus" ) var defaultGosuvDir string