Skip to content

Commit

Permalink
Add additional context to --debug log messages (#28)
Browse files Browse the repository at this point in the history
* Add additional context to --debug log messages

In the `main()` method, in debug mode, we print out the argument
dictionaries a few times but without context for which one is which.
This commit adds an extra line of debug logging each time that indicates
from which point in the process the args are originating. Hopefully this
will expedite any arg parsing debugging.

I've also removed one line of unused code that created an intermediate
object for the argparse object.

* Bump version
  • Loading branch information
jrmontag authored and Aaron Gonzales committed Apr 13, 2018
1 parent a2d2758 commit b19217f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
long_description=open('README.rst', 'r', encoding="utf-8").read(),
author_email='agonzales@twitter.com',
license='MIT',
version='1.4.0',
version='1.5.0',
python_requires='>=3.3',
install_requires=["requests", "tweet_parser", "pyyaml"],
packages=find_packages(),
Expand Down
8 changes: 5 additions & 3 deletions tools/search_tweets.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,20 @@ def parse_cmd_args():


def main():
parser = parse_cmd_args()
args_dict = vars(parse_cmd_args().parse_args())
if args_dict.get("debug") is True:
logger.setLevel(logging.DEBUG)
logger.debug("command line args dict:")
logger.debug(json.dumps(args_dict, indent=4))

if args_dict.get("config_filename") is not None:
configfile_dict = read_config(args_dict["config_filename"])
else:
configfile_dict = {}

logger.debug("config file dict:")
logger.debug(json.dumps(configfile_dict, indent=4))

creds_dict = load_credentials(filename=args_dict["credential_file"],
account_type=args_dict["account_type"],
yaml_key=args_dict["credential_yaml_key"],
Expand All @@ -160,6 +163,7 @@ def main():
dict_filter(args_dict),
dict_filter(creds_dict))

logger.debug("combined dict (cli, config, creds):")
logger.debug(json.dumps(config_dict, indent=4))

if len(dict_filter(config_dict).keys() & REQUIRED_KEYS) < len(REQUIRED_KEYS):
Expand All @@ -169,8 +173,6 @@ def main():

stream_params = gen_params_from_config(config_dict)

logger.debug(json.dumps(config_dict, indent=4))

rs = ResultStream(tweetify=False, **stream_params)

logger.debug(str(rs))
Expand Down

0 comments on commit b19217f

Please sign in to comment.