• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

news4 - RSS aggrigation system


Commit MetaInfo

Revisão1f38193e599003353169196f3064e99ed0f3e4be (tree)
Hora2012-10-19 22:43:22
Autorhylom <hylom@hylo...>
Commiterhylom

Mensagem de Log

add logging utils

Mudança Sumário

Diff

--- a/fetcher.py
+++ b/fetcher.py
@@ -6,6 +6,7 @@ import re
66 import feedparser
77 import dateutil.parser
88 from config import config as config, target_rss as target_rss
9+from logger import log
910
1011 class FeedFetcher(object):
1112 'Feed fetching and parsing'
@@ -34,7 +35,7 @@ class FeedFetcher(object):
3435 def _embeded_filter(self, entry):
3536 # remove PR entry
3637 if re.search(u'^(PR|AD)(:|:)', entry['title']):
37- print 'delete PR entry - %s' % entry['title']
38+ log('delete PR entry - %s' % entry['title'])
3839 return None
3940 return entry
4041
--- a/filters/pr_block.py
+++ b/filters/pr_block.py
@@ -5,7 +5,7 @@ import re
55
66 def entry_filter(entry):
77 if re.search(u'^(PR|AD)(:|:)', entry['title']):
8- print 'delete PR entry - %s' % entry['title']
8+ #print 'delete PR entry - %s' % entry['title']
99 return None
1010 return entry
1111
--- a/gnews.py
+++ b/gnews.py
@@ -6,10 +6,7 @@ import renderer
66 import fetcher
77 import os.path
88 import urllib
9-
10-def _log(*args):
11- "log helper function"
12- print ' '.join(args)
9+from logger import log
1310
1411 def main():
1512 "gnews's main function"
@@ -46,7 +43,7 @@ def main():
4643 entries.sort(cmp_entries)
4744
4845 for e in entries:
49- print e["date"]
46+ log(e["date"])
5047
5148 # do rendering
5249 params = {'tags':tags, 'page':{}, 'sorted_tags':sorted_tags}
@@ -84,7 +81,7 @@ def do_rendering(page_type, filename, entries, params):
8481 else:
8582 output_fullpath = os.path.join(output_dir, filename % page)
8683
87- _log('generate ' + output_fullpath + '...')
84+ log('generate ' + output_fullpath + '...')
8885 f = open(output_fullpath, "w")
8986 html = r.render(tmpl, entries[start:end], params)
9087 f.write(html)
--- a/renderer.py
+++ b/renderer.py
@@ -9,6 +9,7 @@ import dateutil.parser
99
1010 from config import config, target_rss
1111 from propertizer import propertize
12+from logger import log
1213
1314 def date_format(date):
1415 #dt = dateutil.parser.parse(date)
@@ -47,9 +48,9 @@ class Renderer(object):
4748 except:
4849 traceback = RichTraceback()
4950 for (filename, lineno, function, line) in traceback.traceback:
50- print "File %s, line %s, in %s" % (filename, lineno, function)
51- print line, "\n"
52- print "%s: %s" % (str(traceback.error.__class__.__name__), traceback.error)
51+ log("File %s, line %s, in %s" % (filename, lineno, function))
52+ log(line, "\n")
53+ log("%s: %s" % (str(traceback.error.__class__.__name__), traceback.error))
5354 sys.exit(-1)
5455 return result
5556