Skip to content

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
injoyai committed Dec 29, 2023
1 parent 432f94d commit f47e307
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 19 deletions.
26 changes: 15 additions & 11 deletions io_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,22 @@ func newLogger(l Logger) *logger {
return l2
}
return &logger{
Logger: l,
level: LevelAll,
Debugger: true,
coding: nil,
Logger: l,
level: LevelAll,
debug: true,
coding: nil,
}
}

type logger struct {
Logger
Debugger //是否打印调试
level Level //日志等级
coding func(p []byte) string //编码
debug bool //是否打印调试
level Level //日志等级
coding func(p []byte) string //编码
}

func (this *logger) Debug(b ...bool) {
this.debug = len(b) == 0 || b[0]
}

func (this *logger) SetLevel(level Level) {
Expand Down Expand Up @@ -89,7 +93,7 @@ func (this *logger) SetPrintWithBase64() {

// Readln 打印读取到的数据
func (this *logger) Readln(prefix string, p []byte) {
if this.Debugger && LevelRead >= this.level {
if this.debug && LevelRead >= this.level {
if this.coding == nil {
this.SetPrintWithUTF8()
}
Expand All @@ -99,7 +103,7 @@ func (this *logger) Readln(prefix string, p []byte) {

// Writeln 打印写入的数据
func (this *logger) Writeln(prefix string, p []byte) {
if this.Debugger && LevelWrite >= this.level {
if this.debug && LevelWrite >= this.level {
if this.coding == nil {
this.SetPrintWithUTF8()
}
Expand All @@ -109,14 +113,14 @@ func (this *logger) Writeln(prefix string, p []byte) {

// Infof 打印信息
func (this *logger) Infof(format string, v ...interface{}) {
if this.Debugger && LevelInfo >= this.level {
if this.debug && LevelInfo >= this.level {
this.Logger.Infof(format+"\n", v...)
}
}

// Errorf 打印错误
func (this *logger) Errorf(format string, v ...interface{}) {
if this.Debugger && LevelError >= this.level {
if this.debug && LevelError >= this.level {
this.Logger.Errorf(format+"\n", v...)
}
}
Expand Down
8 changes: 0 additions & 8 deletions io_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,3 @@ type Key string
func (this *Key) GetKey() string { return string(*this) }

func (this *Key) SetKey(key string) { *this = Key(key) }

//=================================Debugger=================================

type Debugger bool

func (this *Debugger) Debug(b ...bool) {
*this = Debugger(len(b) == 0 || b[0])
}
Binary file removed testdata/main/proxy.exe
Binary file not shown.
Binary file removed testdata/main/transmit.exe
Binary file not shown.
Binary file removed testdata/main/vpnClient.exe
Binary file not shown.

0 comments on commit f47e307

Please sign in to comment.