diff options
author | jwansek <eddie.atten.ea29@gmail.com> | 2020-07-31 16:12:29 +0100 |
---|---|---|
committer | jwansek <eddie.atten.ea29@gmail.com> | 2020-07-31 16:12:29 +0100 |
commit | 2caf723beae4e1a515e754dcbe5a0ea1cb448d98 (patch) | |
tree | b079742766dbf72927ca4533418edac0549bface /subreddit.py | |
parent | e29f94fcdeddfc563b86545fb22a3b8fca77beb3 (diff) | |
download | SmallYTChannelBot-2caf723beae4e1a515e754dcbe5a0ea1cb448d98.tar.gz SmallYTChannelBot-2caf723beae4e1a515e754dcbe5a0ea1cb448d98.zip |
made logging work
Diffstat (limited to 'subreddit.py')
-rwxr-xr-x | subreddit.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/subreddit.py b/subreddit.py index 9ce5cbe..ff81bc4 100755 --- a/subreddit.py +++ b/subreddit.py @@ -22,21 +22,23 @@ FREE_FLAIRS = CONFIG["free_flairs"] IMGUR = ImgurClient(**CONFIG["imgurapi"]) logging.basicConfig( - format = "[%(asctime)s] %(message)s", + format = "%(process)s\t[%(asctime)s]\t%(message)s", level = logging.INFO, handlers=[ - # logging.FileHandler("actions.log"), + logging.FileHandler("actions.log"), logging.StreamHandler() ]) def get_time(): - #this is not the correct way to do this but I don't care return time.strftime("%b %d %Y %H:%M:%S", time.gmtime()) def display(message, concerning = None): logging.info(message) + + #yes it'd be prettier to do this with a logging.Handler, but alas + #due to `concerning` it'd be more complicated than doing it like this with database.Database() as db: - db.append_log(message, concerning) + db.append_log("%d\t[%s]\t%s" % (os.getpid(), get_time(), message), concerning) def get_lambda_from_flair(s): result = re.search("\[(.*)\]", s) |