-
Notifications
You must be signed in to change notification settings - Fork 258
Combine verbosity-related bool flags into single enum member variable #148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Combine verbosity-related bool flags into single enum member variable #148
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
|
@ehsandeep, PTAL :) |
366413e to
f6f6d02
Compare
forgedhallpass
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case of -v -vv, even though it is redundant, we should not stop the execution. Also, when the execution is stopped, it should probably stop with a non-zero value.
p.s. your example executions above look the same. Please fix it.
f6f6d02 to
28c208d
Compare
|
no flags:
|
I understand your point, and updated the PR accordingly. Please review again. :)
Examples are posted above with the latest patchsets. (FYI, in the previous example, the |
Previously, there were 3 different bool flags related to verbosity. Having many member variables for values that should be mutually exclusive led to a bug where contradicting flags could be set. This caused unexpected behavior with regards to logging. This commit combines the bool flags into 1 int flag. As a result, verbosity level is guaranteed to be mutually exclusive. This commit also adds validation of the verbosity flags and exits with an error msg. Signed-off-by: Myung-jong Kim <mjkim610@gmail.com>
This commit defines a new enum Verbosity. The log level flag Verbosity is converted from int to Verbosity. This has the advantage of clearly defining the human-understandable string values to each choice. It also prevents bugs where an unexpected int value is assigned. Signed-off-by: Myung-jong Kim <mjkim610@gmail.com>
28c208d to
7fe35cd
Compare
ehsandeep
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
./proxify -v -vv
_ ___
___ _______ __ __ (_) _/_ __
/ _ \/ __/ _ \\ \ // / _/ // /
/ .__/_/ \___/_\_\/_/_/ \_, /
/_/ /___/ v0.0.7
projectdiscovery.io
Use with caution. You are responsible for your actions
Developers assume no liability and are not responsible for any misuse or damage.
HTTP Proxy Listening on 127.0.0.1:8888
Socks5 Proxy Listening on 127.0.0.1:10080
Saving traffic to logsproxify $./proxify -v -vv -silent
[ERR] The -silent flag and -v/-vv flags cannot be set together
|
@forgedhallpass any update? :) |
| return options | ||
| } | ||
|
|
||
| func (options *Options) configureVerbosity(silent, verbose, veryVerbose bool) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have imagined controlling the verbosity directly through the logger, without passing around intermediary options. That being said, we can accept it like this now, and will refactor it at a later point in time.
Proposed changes
Previously, there were 3 different bool flags related to verbosity. Having many member variables for values that should be mutually exclusive led to a bug where contradicting flags could be set. This caused unexpected behavior with regards to logging.
This commit combines the bool flags into 1 enum flag. As a result, verbosity level is guaranteed to be mutually exclusive. This commit also adds validation of the verbosity flags and exits with an error msg.
This PR resolves #146.
Checklist