DedSecInside / TorBot

Dark Web OSINT Tool
Other
2.73k stars 509 forks source link

Update main.py #302

Closed vedant-z closed 8 months ago

vedant-z commented 9 months ago

Issue #292

KingAkeem commented 9 months ago

You don't need to open a new PR for each change, you can push commits to the same branch. If you need help with this, just let me know.

In terms of the code, the ArgumentParser is already being instantiated within main.py and the arguments are added within get_args. You can add the verbose flag there. We already have a -v flag so you can name the verbose flag verbose, but not -v.

https://github.com/DedSecInside/TorBot/blob/b68a820b3709d150a567e1399fbec9a61d78ad9a/torbot/main.py#L121-L152

The arguments are read by the perform_action function, you read the argus value there and set the basicConfig for logging which will be applied everywhere.

KingAkeem commented 9 months ago

The log.py file can be removed once this is done, it's redundant.

KingAkeem commented 9 months ago

You've added the argument correctly so great work there, but it still needs to be read so that the logging configuration can be set. My suggestion would be to add a conditional statement to perform_action in main.py that checks for arg.verbose and then sets the basicConfig for logging appropriately.

perform_action

https://github.com/DedSecInside/TorBot/blob/5666f14990a123de71a625da52d72d35b3f37ec1/torbot/main.py#L83-L118

You could use something like

log_level = logging.INFO
if args.verbose:
    log_level = logging.DEBUG
logging.basicConfig(level=log_level, format='%(asctime)s - %(levelname)s - %(message)s', datefmt='%d-%b-%y %H:%M:%S')

This will set the default log_level to info and use debug for verbose logging.