Feature: add silent info level

This commit is contained in:
Dreamacro 2018-12-03 23:41:40 +08:00
parent 6636db242b
commit ca6e67a384
4 changed files with 11 additions and 8 deletions

View file

@ -48,6 +48,9 @@ func updateRules(rules []C.Rule) {
} }
func updateGeneral(general *config.General) { func updateGeneral(general *config.General) {
log.SetLevel(general.LogLevel)
T.Instance().SetMode(general.Mode)
allowLan := general.AllowLan allowLan := general.AllowLan
P.SetAllowLan(allowLan) P.SetAllowLan(allowLan)
@ -62,7 +65,4 @@ func updateGeneral(general *config.General) {
if err := P.ReCreateRedir(general.RedirPort); err != nil { if err := P.ReCreateRedir(general.RedirPort); err != nil {
log.Errorln("Start Redir server error: %s", err.Error()) log.Errorln("Start Redir server error: %s", err.Error())
} }
log.SetLevel(general.LogLevel)
T.Instance().SetMode(general.Mode)
} }

View file

@ -14,6 +14,7 @@ var (
"warning": WARNING, "warning": WARNING,
"info": INFO, "info": INFO,
"debug": DEBUG, "debug": DEBUG,
"silent": SILENT,
} }
) )
@ -22,6 +23,7 @@ const (
INFO INFO
WARNING WARNING
ERROR ERROR
SILENT
) )
type LogLevel int type LogLevel int
@ -70,6 +72,8 @@ func (l LogLevel) String() string {
return "error" return "error"
case DEBUG: case DEBUG:
return "debug" return "debug"
case SILENT:
return "silent"
default: default:
return "unknow" return "unknow"
} }

View file

@ -4,9 +4,8 @@ import (
"net" "net"
"github.com/Dreamacro/clash/adapters/inbound" "github.com/Dreamacro/clash/adapters/inbound"
"github.com/Dreamacro/clash/log"
"github.com/Dreamacro/clash/tunnel" "github.com/Dreamacro/clash/tunnel"
log "github.com/sirupsen/logrus"
) )
var ( var (
@ -27,7 +26,7 @@ func NewRedirProxy(addr string) (*redirListener, error) {
rl := &redirListener{l, addr, false} rl := &redirListener{l, addr, false}
go func() { go func() {
log.Infof("Redir proxy listening at: %s", addr) log.Infoln("Redir proxy listening at: %s", addr)
for { for {
c, err := l.Accept() c, err := l.Accept()
if err != nil { if err != nil {

View file

@ -4,10 +4,10 @@ import (
"net" "net"
"github.com/Dreamacro/clash/adapters/inbound" "github.com/Dreamacro/clash/adapters/inbound"
"github.com/Dreamacro/clash/log"
"github.com/Dreamacro/clash/tunnel" "github.com/Dreamacro/clash/tunnel"
"github.com/Dreamacro/go-shadowsocks2/socks" "github.com/Dreamacro/go-shadowsocks2/socks"
log "github.com/sirupsen/logrus"
) )
var ( var (
@ -28,7 +28,7 @@ func NewSocksProxy(addr string) (*sockListener, error) {
sl := &sockListener{l, addr, false} sl := &sockListener{l, addr, false}
go func() { go func() {
log.Infof("SOCKS proxy listening at: %s", addr) log.Infoln("SOCKS proxy listening at: %s", addr)
for { for {
c, err := l.Accept() c, err := l.Accept()
if err != nil { if err != nil {