aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsource/log.py2
-rwxr-xr-xsource/utils.py10
2 files changed, 10 insertions, 2 deletions
diff --git a/source/log.py b/source/log.py
index 071ab5c8..5db5d838 100755
--- a/source/log.py
+++ b/source/log.py
@@ -36,7 +36,7 @@ class Log(object):
"""
import logging
self.logger = logging.getLogger("pyaggr3g470r")
- hdlr = logging.FileHandler('./var/access.log')
+ hdlr = logging.FileHandler('./var/pyaggr3g470r.log')
formater = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
hdlr.setFormatter(formater)
self.logger.addHandler(hdlr)
diff --git a/source/utils.py b/source/utils.py
index e2bf69ab..4699a20b 100755
--- a/source/utils.py
+++ b/source/utils.py
@@ -68,6 +68,9 @@ url_finders = [ \
re.compile("'\\<((mailto:)|)[-A-Za-z0-9\\.]+@[-A-Za-z0-9\\.]+") \
]
+import log
+pyaggr3g470r_log = log.Log()
+
@contextmanager
def opened_w_error(filename, mode="r"):
try:
@@ -97,13 +100,18 @@ def open_url(url):
except urllib.error.HTTPError as e:
# server couldn't fulfill the request
errors.append((url, e.code, \
- http.server.BaseHTTPRequestHandler.responses[e.code][1]))
+ http.server.BaseHTTPRequestHandler.responses[e.code][1]))
+ pyaggr3g470r_log.error(url + " " + e.code + " " + \
+ http.server.BaseHTTPRequestHandler.responses[e.code][1])
except urllib.error.URLError as e:
# failed to reach the server
if type(e.reason) == str:
errors.append((url, e.reason, e.reason))
+ pyaggr3g470r_log.error(URL + " " + e.reason)
else:
errors.append((url, e.reason.errno, e.reason.strerror))
+ pyaggr3g470r_log.error(URL + " " + e.reason.errno + " " + \
+ e.reason.strerror)
return (False, errors)
def generate_qr_code(article):
bgstack15