From 65fbf900050694128707320e257ebdf53fb40491 Mon Sep 17 00:00:00 2001 From: David Trail Date: Fri, 30 Sep 2016 13:38:51 +0100 Subject: [PATCH] Debug level added to config --- shreddit.py | 9 +++++---- shreddit.yml.example | 8 ++++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/shreddit.py b/shreddit.py index 1e744c9..0a0d144 100755 --- a/shreddit.py +++ b/shreddit.py @@ -17,7 +17,7 @@ from praw.objects import Comment, Submission logging.basicConfig(stream=sys.stdout) log = logging.getLogger(__name__) -log.setLevel(level=logging.WARNING) +log.setLevel(level=logging.DEBUG) try: from loremipsum import get_sentence # This only works on Python 2 @@ -58,12 +58,13 @@ if config is None: save_directory = config.get('save_directory', '.') -r = praw.Reddit(user_agent="shreddit/4.2") +r = praw.Reddit(user_agent="shreddit/4.3") if save_directory: r.config.store_json_result = True if config.get('verbose', True): - log.setLevel(level=logging.DEBUG) + log_level = config.get('debug', 'WARNING') # Default to WARNING only + log.setLevel(level=getattr(logging, log_level)) try: # Try to login with OAuth2 @@ -176,7 +177,7 @@ def remove_things(things): replacement_text[:78], thing.subreddit ) - + if config.get('edit_only'): log.info('Editing (not removing) {msg}'.format(msg=msg)) else: diff --git a/shreddit.yml.example b/shreddit.yml.example index f23bf0d..81de823 100644 --- a/shreddit.yml.example +++ b/shreddit.yml.example @@ -2,8 +2,8 @@ # Login details for Reddit. Fill out if you don't wish # to be prompted for a login every time you run Shreddit. ### NOTE: This may be deprecated as you can specify in praw.ini instead -username: -password: +username: +password: # How many hours of comments you want to keep # 24 hours in a day, @@ -68,4 +68,8 @@ save_directory: /tmp # options: [random, dot, "user entered string"] replacement_format: random +# Debug level, how much output you want +# See: https://docs.python.org/3/library/logging.html#logging-levels +debug: DEBUG + # vim: syntax=yaml ts=2