a
This commit is contained in:
parent
6b900ef16d
commit
8c552af606
10
app.py
10
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()
|
||||
app.run(debug=True)
|
||||
|
Loading…
x
Reference in New Issue
Block a user