From 3f774a9e38c002488611d1760fd18a1d46a4ef5f Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Mon, 6 Sep 2021 00:21:05 +0000 Subject: [PATCH] Improve logging --- apiserver/feeds/reddit.py | 8 ++++---- apiserver/feeds/tildes.py | 8 ++++---- apiserver/server.py | 4 +++- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/apiserver/feeds/reddit.py b/apiserver/feeds/reddit.py index 3268066..e3c5c6d 100644 --- a/apiserver/feeds/reddit.py +++ b/apiserver/feeds/reddit.py @@ -33,10 +33,10 @@ def feed(): except KeyboardInterrupt: raise except PRAWException as e: - logging.error('Problem hitting reddit API: {}'.format(str(e))) + logging.critical('Problem hitting reddit API: {}'.format(str(e))) return [] except PrawcoreException as e: - logging.error('Problem hitting reddit API: {}'.format(str(e))) + logging.critical('Problem hitting reddit API: {}'.format(str(e))) return [] def comment(i): @@ -84,10 +84,10 @@ def story(ref): except KeyboardInterrupt: raise except PRAWException as e: - logging.error('Problem hitting reddit API: {}'.format(str(e))) + logging.critical('Problem hitting reddit API: {}'.format(str(e))) return False except PrawcoreException as e: - logging.error('Problem hitting reddit API: {}'.format(str(e))) + logging.critical('Problem hitting reddit API: {}'.format(str(e))) return False # scratchpad so I can quickly develop the parser diff --git a/apiserver/feeds/tildes.py b/apiserver/feeds/tildes.py index 3b7051a..5c7a9e9 100644 --- a/apiserver/feeds/tildes.py +++ b/apiserver/feeds/tildes.py @@ -34,7 +34,7 @@ def api(route): except KeyboardInterrupt: raise except BaseException as e: - logging.error('Problem hitting tildes website: {}'.format(str(e))) + logging.critical('Problem hitting tildes website: {}'.format(str(e))) return False def feed(): @@ -113,7 +113,7 @@ def story(ref): # scratchpad so I can quickly develop the parser if __name__ == '__main__': - #print(feed()) + print(feed()) #normal = story('gxt') #print(normal) #no_comments = story('gxr') @@ -122,8 +122,8 @@ if __name__ == '__main__': #print(self_post) #li_comment = story('gqx') #print(li_comment) - broken = story('q4y') - print(broken) + #broken = story('q4y') + #print(broken) # make sure there's no self-reference #import copy diff --git a/apiserver/server.py b/apiserver/server.py index 8aee440..6b1d6ea 100644 --- a/apiserver/server.py +++ b/apiserver/server.py @@ -65,6 +65,8 @@ def submit(): url = request.form['url'] nid = new_id() + logging.info('Manual submission: ' + url) + parse = urlparse(url) if 'news.ycombinator.com' in parse.hostname: source = 'hackernews' @@ -200,7 +202,7 @@ def feed_thread(): except KeyboardInterrupt: logging.info('Ending feed thread...') except ValueError as e: - logging.error('feed_thread error: {} {}'.format(e.__class__.__name__, e)) + logging.critical('feed_thread error: {} {}'.format(e.__class__.__name__, e)) http_server.stop() print('Starting Feed thread...')