进一步优化日志输出, 减少非必要输出

This commit is contained in:
M09Ic committed 2024-02-20 21:28:07 +08:00
1 parent a2896845cf
commit 6f8cd01736
2 files changed
+16 -16

No files matched your search

+4 -4
View File
@@ -340,14 +340,14 @@ func (r *Runner) PrintStat(pool *pool.BrutePool) {
if r.Color {
logs.Log.Important(pool.Statistor.ColorString())
if pool.Statistor.Error == "" {
pool.Statistor.PrintColorCount()
pool.Statistor.PrintColorSource()
logs.Log.Log(pkg.LogVerbose, pool.Statistor.ColorCountString())
logs.Log.Log(pkg.LogVerbose, pool.Statistor.ColorSourceString())
}
} else {
logs.Log.Important(pool.Statistor.String())
if pool.Statistor.Error == "" {
pool.Statistor.PrintCount()
pool.Statistor.PrintSource()
logs.Log.Log(pkg.LogVerbose, pool.Statistor.CountString())
logs.Log.Log(pkg.LogVerbose, pool.Statistor.SourceString())
}
}
+12 -12
View File
@@ -111,9 +111,9 @@ func (stat *Statistor) String() string {
return s.String()
}
func (stat *Statistor) PrintCount() {
func (stat *Statistor) CountString() string {
if len(stat.Counts) == 0 {
return
return ""
}
var s strings.Builder
s.WriteString("[stat] ")
@@ -124,12 +124,12 @@ func (stat *Statistor) PrintCount() {
}
s.WriteString(fmt.Sprintf(" %d: %d,", k, v))
}
logs.Log.Important(s.String())
return s.String()
}
func (stat *Statistor) PrintSource() {
func (stat *Statistor) SourceString() string {
if len(stat.Sources) == 0 {
return
return ""
}
var s strings.Builder
s.WriteString("[stat] ")
@@ -137,12 +137,12 @@ func (stat *Statistor) PrintSource() {
for k, v := range stat.Sources {
s.WriteString(fmt.Sprintf(" %s: %d,", k.Name(), v))
}
logs.Log.Important(s.String())
return s.String()
}
func (stat *Statistor) PrintColorCount() {
func (stat *Statistor) ColorCountString() string {
if len(stat.Counts) == 0 {
return
return ""
}
var s strings.Builder
s.WriteString(fmt.Sprintf("[stat] %s ", stat.BaseUrl))
@@ -152,19 +152,19 @@ func (stat *Statistor) PrintColorCount() {
}
s.WriteString(fmt.Sprintf(" %s: %s,", logs.Cyan(strconv.Itoa(k)), logs.YellowBold(strconv.Itoa(v))))
}
logs.Log.Important(s.String())
return s.String()
}
func (stat *Statistor) PrintColorSource() {
func (stat *Statistor) ColorSourceString() string {
if len(stat.Sources) == 0 {
return
return ""
}
var s strings.Builder
s.WriteString(fmt.Sprintf("[stat] %s ", stat.BaseUrl))
for k, v := range stat.Sources {
s.WriteString(fmt.Sprintf(" %s: %s,", logs.Cyan(k.Name()), logs.YellowBold(strconv.Itoa(v))))
}
logs.Log.Important(s.String())
return s.String()
}
func (stat *Statistor) Json() string {