aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r
diff options
context:
space:
mode:
Diffstat (limited to 'pyaggr3g470r')
-rw-r--r--pyaggr3g470r/feedgetter.py11
-rwxr-xr-xpyaggr3g470r/log.py12
2 files changed, 13 insertions, 10 deletions
diff --git a/pyaggr3g470r/feedgetter.py b/pyaggr3g470r/feedgetter.py
index c7f7f81e..b27b63af 100644
--- a/pyaggr3g470r/feedgetter.py
+++ b/pyaggr3g470r/feedgetter.py
@@ -42,8 +42,8 @@ import utils
from flask.ext.mail import Message
from pyaggr3g470r import app, mail
-#import log
-#pyaggr3g470r_log = log.Log()
+import log
+pyaggr3g470r_log = log.Log("feedgetter")
list_of_threads = []
@@ -99,6 +99,7 @@ class FeedGetter(object):
parsed_url = urlparse(r.url)
real_url = parsed_url.scheme + '://' + parsed_url.netloc + parsed_url.path
except:
+ pyaggr3g470r_log.warning("Unable to get the real URL of " + article.link)
real_url = article.link
if models.Article.objects(link=real_url).first() != None:
@@ -132,7 +133,8 @@ class FeedGetter(object):
article = models.Article(post_date, real_url, article_title, description, False, False)
try:
article.save()
- except:
+ except Exception as e:
+ pyaggr3g470r_log.error("Error when inserting article in database: " + str(e))
continue
articles.append(article)
@@ -140,8 +142,7 @@ class FeedGetter(object):
try:
search.add_to_index([article], feed)
except Exception as e:
- print("Whoosh error: " + str(e))
- #pyaggr3g470r_log.error("Whoosh error.")
+ pyaggr3g470r_log.error("Whoosh error.")
continue
# email notification
diff --git a/pyaggr3g470r/log.py b/pyaggr3g470r/log.py
index 9c86be74..22834e71 100755
--- a/pyaggr3g470r/log.py
+++ b/pyaggr3g470r/log.py
@@ -20,22 +20,24 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>
__author__ = "Cedric Bonhomme"
-__version__ = "$Revision: 0.1 $"
+__version__ = "$Revision: 0.2 $"
__date__ = "$Date: 2012/10/12 $"
-__revision__ = "$Date: 2012/10/12 $"
+__revision__ = "$Date: 2013/12/26 $"
__copyright__ = "Copyright (c) Cedric Bonhomme"
__license__ = "GPLv3"
+import logging
+
class Log(object):
"""
Log events. Especially events relative to authentication.
"""
- def __init__(self):
+ def __init__(self, module_name):
"""
Initialization of the logger.
"""
- import logging
- self.logger = logging.getLogger("pyaggr3g470r")
+ self.logger = logging.getLogger(module_name)
+ self.logger.propagate = False
hdlr = logging.FileHandler('./pyaggr3g470r/var/pyaggr3g470r.log')
formater = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
hdlr.setFormatter(formater)
bgstack15