Skip to content

Commit be6aff9

Browse files
authored
Merge pull request #6 from projectdiscovery/add-debug
Add debug statements to logs
2 parents 16be7f3 + 323e03b commit be6aff9

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

pkg/log/log.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const (
2222
Error
2323
Info
2424
Warning
25+
Debug
2526
Verbose
2627
)
2728

@@ -38,6 +39,7 @@ var (
3839
Error: "ERR",
3940
Label: "WRN",
4041
Fatal: "FTL",
42+
Debug: "DBG",
4143
Info: "INF",
4244
}
4345

@@ -65,6 +67,8 @@ func wrap(label string, level Level) string {
6567
return aurora.Bold(aurora.Red(label)).String()
6668
case Error:
6769
return aurora.Red(label).String()
70+
case Debug:
71+
return aurora.Magenta(label).String()
6872
case Warning, Label:
6973
return aurora.Yellow(label).String()
7074
default:
@@ -78,7 +82,7 @@ func getLabel(level Level, label string, sb *strings.Builder) {
7882
switch level {
7983
case Silent, Misc:
8084
return
81-
case Error, Fatal, Info, Warning, Label:
85+
case Error, Fatal, Info, Warning, Debug, Label:
8286
sb.WriteString("[")
8387
sb.WriteString(wrap(labels[level], level))
8488
sb.WriteString("]")
@@ -145,6 +149,11 @@ func Errorf(format string, args ...interface{}) {
145149
log(Error, "", format, args...)
146150
}
147151

152+
// Debugf writes an error message on the screen with the default label
153+
func Debugf(format string, args ...interface{}) {
154+
log(Debug, "", format, args...)
155+
}
156+
148157
// Verbosef writes a verbose message on the screen with a tabel
149158
func Verbosef(format string, label string, args ...interface{}) {
150159
log(Verbose, label, format, args...)

pkg/scan/scan.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import (
1313
"github.com/google/gopacket/layers"
1414
"github.com/google/gopacket/pcap"
1515
"github.com/phayes/freeport"
16+
17+
"github.com/projectdiscovery/naabu/pkg/log"
1618
)
1719

1820
// Scanner is a scanner that scans for ports using SYN packets.
@@ -128,6 +130,8 @@ func (s *Scanner) Scan(wordlist map[int]struct{}) (*Result, error) {
128130

129131
go func() {
130132
for open := range openChan {
133+
log.Debugf("Found active port %d on %s\n", open, s.host.String())
134+
131135
results.Ports[open] = struct{}{}
132136
}
133137
resultsWg.Done()

0 commit comments

Comments
 (0)