mirror of
https://github.com/bettercap/bettercap
synced 2025-07-14 00:53:46 -07:00
refact: refactored to use islazy and updated deps
This commit is contained in:
parent
a2b3ee79fb
commit
d070445225
238 changed files with 12662 additions and 1586 deletions
|
@ -7,7 +7,8 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/bettercap/bettercap/core"
|
||||
"github.com/evilsocket/islazy/log"
|
||||
"github.com/evilsocket/islazy/tui"
|
||||
)
|
||||
|
||||
type Event struct {
|
||||
|
@ -17,7 +18,7 @@ type Event struct {
|
|||
}
|
||||
|
||||
type LogMessage struct {
|
||||
Level int
|
||||
Level log.Verbosity
|
||||
Message string
|
||||
}
|
||||
|
||||
|
@ -30,10 +31,10 @@ func NewEvent(tag string, data interface{}) Event {
|
|||
}
|
||||
|
||||
func (e Event) Label() string {
|
||||
log := e.Data.(LogMessage)
|
||||
label := core.LogLabels[log.Level]
|
||||
color := core.LogColors[log.Level]
|
||||
return color + label + core.RESET
|
||||
m := e.Data.(LogMessage)
|
||||
label := log.LevelNames[m.Level]
|
||||
color := log.LevelColors[m.Level]
|
||||
return color + label + tui.RESET
|
||||
}
|
||||
|
||||
type EventPool struct {
|
||||
|
@ -114,10 +115,10 @@ func (p *EventPool) Add(tag string, data interface{}) {
|
|||
}
|
||||
}
|
||||
|
||||
func (p *EventPool) Log(level int, format string, args ...interface{}) {
|
||||
if level == core.DEBUG && !p.debug {
|
||||
func (p *EventPool) Log(level log.Verbosity, format string, args ...interface{}) {
|
||||
if level == log.DEBUG && !p.debug {
|
||||
return
|
||||
} else if level < core.ERROR && p.silent {
|
||||
} else if level < log.ERROR && p.silent {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -128,7 +129,7 @@ func (p *EventPool) Log(level int, format string, args ...interface{}) {
|
|||
message,
|
||||
})
|
||||
|
||||
if level == core.FATAL {
|
||||
if level == log.FATAL {
|
||||
fmt.Fprintf(os.Stderr, "%s\n", message)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue