Files
petpicturequeue/app/utils/logging_config.py
2025-08-07 18:18:36 -04:00

32 lines
895 B
Python

"""
Logging configuration
"""
import logging
import os
from logging.handlers import RotatingFileHandler
def setup_logging(app):
"""Setup application logging"""
if not app.debug and not app.testing:
# Production logging setup
if not os.path.exists('logs'):
os.mkdir('logs')
file_handler = RotatingFileHandler(
'logs/pets_powerwashing.log',
maxBytes=10240,
backupCount=10
)
file_handler.setFormatter(logging.Formatter(
'%(asctime)s %(levelname)s: %(message)s [in %(pathname)s:%(lineno)d]'
))
file_handler.setLevel(logging.INFO)
app.logger.addHandler(file_handler)
app.logger.setLevel(logging.INFO)
app.logger.info('Pets of Powerwashing startup')
else:
# Development logging
app.logger.setLevel(logging.DEBUG)