commit 9c10511a8f0ae3e88a7ae9fa3785108995fe66e1 Author: ilv ilv@users.noreply.github.com Date: Tue Nov 17 00:37:49 2015 -0300
Simple logging string for stats (Deleted redundant info) --- gettor/smtp.py | 13 +++++-------- gettor/twitter.py | 11 ++++------- gettor/xmpp.py | 13 +++++-------- 3 files changed, 14 insertions(+), 23 deletions(-)
diff --git a/gettor/smtp.py b/gettor/smtp.py index 9203039..d6de2ed 100644 --- a/gettor/smtp.py +++ b/gettor/smtp.py @@ -462,14 +462,14 @@ class SMTP(object): norm_from_addr = self._get_normalized_address(from_addr) except AddressError as e: bogus_request = True - self.log.info('REQUEST: invalid; OS: none; LC: none') + self.log.info('invalid; none; none')
if norm_from_addr: anon_addr = utils.get_sha256(norm_from_addr)
if self._is_blacklisted(anon_addr): bogus_request = True - self.log.info('REQUEST: blacklist; OS: none; LC: none') + self.log.info('blacklist; none; none')
if not bogus_request: # try to figure out what the user is asking @@ -482,8 +482,7 @@ class SMTP(object): # possible options: help, links, mirrors if req['type'] == 'help': self.log.debug("Trying to send help...") - self.log.info('REQUEST: help; OS: none; LC: %s' % - req['lc']) + self.log.info('help; none; %s' % req['lc']) # make sure we can send emails try: self._send_help('en', our_addr, norm_from_addr) @@ -494,8 +493,7 @@ class SMTP(object):
elif req['type'] == 'mirrors': self.log.debug("Trying to send the mirrors...") - self.log.info('REQUEST: mirrors; OS: none; LC: %s' % - req['lc']) + self.log.info('mirrors; none; %s' % req['lc']) # make sure we can send emails try: self._send_mirrors('en', our_addr, norm_from_addr) @@ -506,8 +504,7 @@ class SMTP(object):
elif req['type'] == 'links': self.log.debug("Trying to obtain the links...") - self.log.info('REQUEST: links; OS: %s; LC: %s' % - req['os '], req['lc']) + self.log.info('links; %s; %s' % (req['os '], req['lc']))
try: links = self.core.get_links( diff --git a/gettor/twitter.py b/gettor/twitter.py index 85cad47..f4b934f 100644 --- a/gettor/twitter.py +++ b/gettor/twitter.py @@ -218,7 +218,7 @@ class TwitterBot(object):
try: if self._is_blacklisted(str(sender_id)): - self.log.info('REQUEST: blacklist; OS: none; LC: none') + self.log.info('blacklist; none; none') bogus_request = True
if not bogus_request: @@ -228,8 +228,7 @@ class TwitterBot(object):
# possible options: links, mirrors, help if request['type'] == 'links': - self.log.info('REQUEST: links; OS: %s; LC: %s' % - (req['os'], req['lc'])) + self.log.info('links; %s; %s' % (req['os'], req['lc'])) links = self.core.get_links( 'Twitter', request['os'], @@ -240,8 +239,7 @@ class TwitterBot(object): reply = reply % (request['os'], request['lc'], links)
elif request['type'] == 'mirrors': - self.log.info('REQUEST: mirrors; OS: none; LC: %s' % - req['lc']) + self.log.info('mirrors; none; %s' % req['lc']) reply = self._get_msg('mirrors', 'en') try: with open(self.mirrors, "r") as list_mirrors: @@ -252,8 +250,7 @@ class TwitterBot(object): reply = self._get_msg('mirrors_unavailable', 'en')
else: - self.log.info('REQUEST: help; OS: none; LC: %s' % - req['lc']) + self.log.info('help; none; %s' % req['lc']) reply = self._get_msg('help', 'en')
self.api.send_direct_message( diff --git a/gettor/xmpp.py b/gettor/xmpp.py index 072d988..1bea716 100644 --- a/gettor/xmpp.py +++ b/gettor/xmpp.py @@ -277,7 +277,7 @@ class XMPP(object): self.log.debug("Parsing request") try: if self._is_blacklisted(str(account)): - self.log.info('REQUEST: blacklist; OS: none; LC: none') + self.log.info('blacklist; none; none') bogus_request = True
# first let's find out how many words are in the message @@ -286,7 +286,7 @@ class XMPP(object): if len(words) > self.max_words: bogus_request = True self.log.info("Message way too long") - self.log.info('REQUEST: invalid; OS: none; LC: none') + self.log.info('invalid; none; none') reply = self._get_msg('message_error', 'en')
if not bogus_request: @@ -295,13 +295,11 @@ class XMPP(object): req = self._parse_text(str(msg))
if req['type'] == 'help': - self.log.info('REQUEST: help; OS: none; LC: %s' % - req['lc']) + self.log.info('help; none; %s' % req['lc']) reply = self._get_msg('help', 'en')
elif req['type'] == 'mirrors': - self.log.info('REQUEST: mirrors; OS: none; LC: %s' % - req['lc']) + self.log.info('mirrors; none; %s' % req['lc']) reply = self._get_msg('mirrors', 'en') try: with open(self.mirrors, "r") as list_mirrors: @@ -311,8 +309,7 @@ class XMPP(object): reply = self._get_msg('mirrors_unavailable', 'en')
elif req['type'] == 'links': - self.log.info('REQUEST: links; OS: %s; LC: %s' % - (req['os'], req['lc'])) + self.log.info('links; %s; %s' % (req['os'], req['lc'])) links = self.core.get_links( "XMPP", req['os'],