Skip to content

Commit cf9142b

Browse files
authored
Merge pull request #825 from projectdiscovery/fix_lib_log_config_issue
fix lib log config issue
2 parents 01b708d + 7c42305 commit cf9142b

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed

internal/runner/options.go

-17
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@ import (
99

1010
"github.com/projectdiscovery/gologger"
1111
"github.com/projectdiscovery/gologger/formatter"
12-
"github.com/projectdiscovery/gologger/levels"
1312
"github.com/projectdiscovery/katana/pkg/types"
1413
"github.com/projectdiscovery/katana/pkg/utils"
1514
errorutil "github.com/projectdiscovery/utils/errors"
1615
fileutil "github.com/projectdiscovery/utils/file"
17-
logutil "github.com/projectdiscovery/utils/log"
1816
"gopkg.in/yaml.v3"
1917
)
2018

@@ -110,21 +108,6 @@ func normalizeInput(value string) string {
110108
return strings.TrimSpace(value)
111109
}
112110

113-
// configureOutput configures the output logging levels to be displayed on the screen
114-
func configureOutput(options *types.Options) {
115-
if options.Silent {
116-
gologger.DefaultLogger.SetMaxLevel(levels.LevelSilent)
117-
} else if options.Verbose {
118-
gologger.DefaultLogger.SetMaxLevel(levels.LevelWarning)
119-
} else if options.Debug {
120-
gologger.DefaultLogger.SetMaxLevel(levels.LevelDebug)
121-
} else {
122-
gologger.DefaultLogger.SetMaxLevel(levels.LevelInfo)
123-
}
124-
125-
logutil.DisableDefaultLogger()
126-
}
127-
128111
func initExampleFormFillConfig() error {
129112
homedir, err := os.UserHomeDir()
130113
if err != nil {

internal/runner/runner.go

-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ func New(options *types.Options) (*Runner, error) {
5757
options.URLs = mapsutil.GetKeys(runnerState.InFlightUrls.GetAll())
5858
}
5959

60-
configureOutput(options)
6160
showBanner()
6261

6362
if options.Version {

pkg/types/crawler_options.go

+19
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@ import (
66
"time"
77

88
"github.com/projectdiscovery/fastdialer/fastdialer"
9+
"github.com/projectdiscovery/gologger"
10+
"github.com/projectdiscovery/gologger/levels"
911
"github.com/projectdiscovery/katana/pkg/output"
1012
"github.com/projectdiscovery/katana/pkg/utils/extensions"
1113
"github.com/projectdiscovery/katana/pkg/utils/filters"
1214
"github.com/projectdiscovery/katana/pkg/utils/scope"
1315
"github.com/projectdiscovery/ratelimit"
1416
errorutil "github.com/projectdiscovery/utils/errors"
17+
logutil "github.com/projectdiscovery/utils/log"
1518
urlutil "github.com/projectdiscovery/utils/url"
1619
wappalyzer "github.com/projectdiscovery/wappalyzergo"
1720
)
@@ -39,6 +42,7 @@ type CrawlerOptions struct {
3942
// NewCrawlerOptions creates a new crawler options structure
4043
// from user specified options.
4144
func NewCrawlerOptions(options *Options) (*CrawlerOptions, error) {
45+
configureOutput(options)
4246
extensionsValidator := extensions.NewValidator(options.ExtensionsMatch, options.ExtensionFilter)
4347

4448
dialerOpts := fastdialer.DefaultOptions
@@ -147,3 +151,18 @@ func (c *CrawlerOptions) ValidateScope(absURL, rootHostname string) (bool, error
147151
}
148152
return true, nil
149153
}
154+
155+
// configureOutput configures the output logging levels to be displayed on the screen
156+
func configureOutput(options *Options) {
157+
if options.Silent {
158+
gologger.DefaultLogger.SetMaxLevel(levels.LevelSilent)
159+
} else if options.Verbose {
160+
gologger.DefaultLogger.SetMaxLevel(levels.LevelWarning)
161+
} else if options.Debug {
162+
gologger.DefaultLogger.SetMaxLevel(levels.LevelDebug)
163+
} else {
164+
gologger.DefaultLogger.SetMaxLevel(levels.LevelInfo)
165+
}
166+
167+
logutil.DisableDefaultLogger()
168+
}

0 commit comments

Comments
 (0)