Skip to content
This repository has been archived by the owner on Sep 12, 2022. It is now read-only.

Commit

Permalink
Add logging to rule matching
Browse files Browse the repository at this point in the history
Whether Traptor matches a tweet to a rule or doesn’t, it logs it.
  • Loading branch information
rdempsey committed May 24, 2016
1 parent ec6a194 commit e8acb3d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions traptor/traptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ def _add_rule_tag_and_value_to_tweet(self, tweet_dict, search_str, matched_rule)
# Pass all key/value pairs from matched rule through to Traptor
for key, value in matched_rule.iteritems():
tweet_dict['traptor'][key] = value

# Log that a rule was matched
self.logger.info("Rule matched for tweet id: {}".format(tweet_dict['id_str']))

return tweet_dict

Expand Down Expand Up @@ -280,6 +283,8 @@ def _find_rule_matches(self, tweet_dict):
if 'rule_tag' not in new_dict['traptor']:
new_dict['traptor']['rule_tag'] = 'Not found'
new_dict['traptor']['rule_value'] = 'Not found'
# Log that a rule was matched
self.logger.warning("No rule matched for tweet id: {}".format(tweet_dict['id_str']))

return new_dict

Expand Down

0 comments on commit e8acb3d

Please sign in to comment.