From 382cf5d5010994000f59930fb365f8b5cc0969b7 Mon Sep 17 00:00:00 2001 From: Michal Tuszowski Date: Thu, 18 Apr 2024 00:03:44 +0200 Subject: [PATCH] Fix logging with rotation --- conjurer_librarian/conjurer_librarian.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/conjurer_librarian/conjurer_librarian.py b/conjurer_librarian/conjurer_librarian.py index 1a322ab..9740009 100644 --- a/conjurer_librarian/conjurer_librarian.py +++ b/conjurer_librarian/conjurer_librarian.py @@ -1,3 +1,4 @@ +from logging import handlers import re import logging import threading @@ -313,6 +314,15 @@ async def get_partial(): #=======================================MAIN=================================================== if __name__ == "__main__": app.logger.setLevel(logging.DEBUG) + h1 = handlers.RotatingFileHandler( + filename="E:\\logs\\librarian.log", + encoding="utf-8", + mode="a", + maxBytes=6 * 1024 * 1024, + backupCount=6, + ) + + app.logger.addHandler(h1) threads = [] threads.append(threading.Thread(target=waitress_run)) #threads.append(threading.Thread(target=flask_debug))