From 8c552af606bf7f7910c21c0378b7f2a329649ec7 Mon Sep 17 00:00:00 2001 From: zman Date: Tue, 8 Apr 2025 10:33:46 -0400 Subject: [PATCH] a --- app.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index ed67dbe..c626bda 100644 --- a/app.py +++ b/app.py @@ -16,12 +16,19 @@ app = Flask(__name__) # Set up logging log_file = 'log.txt' + +# Create a rotating file handler for logging log_handler = RotatingFileHandler(log_file, maxBytes=10*1024*1024, backupCount=5) # 10MB per log file, keep 5 backups log_handler.setLevel(logging.DEBUG) log_formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s') log_handler.setFormatter(log_formatter) + +# Add the log handler to the Flask app's logger app.logger.addHandler(log_handler) +# Ensure Flask app uses our logger, not its default one +app.logger.setLevel(logging.DEBUG) + # Create a queue to hold the files for processing file_queue = queue.Queue() @@ -91,7 +98,6 @@ def print_address_label(pdf_path): backend_identifier=backend, blocking=True ) - app.logger.info(f"Printer status: {status}") app.logger.info("Print job sent successfully") except Exception as e: @@ -144,4 +150,4 @@ def upload_file(): return jsonify({'message': f'File {file.filename} uploaded and queued for processing'}), 200 if __name__ == '__main__': - app.run() \ No newline at end of file + app.run(debug=True)