# Logging configuration for Ad-tlas Django application
# Production-ready logging setup with proper formatting and rotation

[loggers]
keys=root,django,django.request,django.security,django.db.backends,celery,gunicorn,adtlas

[handlers]
keys=console,file,error_file,security_file,celery_file,gunicorn_access,gunicorn_error,syslog

[formatters]
keys=verbose,simple,json,syslog

# =============================================================================
# Loggers Configuration
# =============================================================================

[logger_root]
level=INFO
handlers=console,file
qualname=root

[logger_django]
level=INFO
handlers=console,file
qualname=django
propagate=0

[logger_django.request]
level=WARNING
handlers=console,error_file
qualname=django.request
propagate=0

[logger_django.security]
level=WARNING
handlers=console,security_file
qualname=django.security
propagate=0

[logger_django.db.backends]
level=WARNING
handlers=console,file
qualname=django.db.backends
propagate=0

[logger_celery]
level=INFO
handlers=console,celery_file
qualname=celery
propagate=0

[logger_gunicorn]
level=INFO
handlers=gunicorn_access,gunicorn_error
qualname=gunicorn
propagate=0

[logger_adtlas]
level=INFO
handlers=console,file
qualname=adtlas
propagate=0

# =============================================================================
# Handlers Configuration
# =============================================================================

[handler_console]
class=StreamHandler
level=INFO
formatter=simple
args=(sys.stdout,)

[handler_file]
class=handlers.RotatingFileHandler
level=INFO
formatter=verbose
args=('/app/logs/django.log', 'a', 10485760, 5, 'utf-8')

[handler_error_file]
class=handlers.RotatingFileHandler
level=ERROR
formatter=verbose
args=('/app/logs/django-error.log', 'a', 10485760, 5, 'utf-8')

[handler_security_file]
class=handlers.RotatingFileHandler
level=WARNING
formatter=verbose
args=('/app/logs/django-security.log', 'a', 10485760, 5, 'utf-8')

[handler_celery_file]
class=handlers.RotatingFileHandler
level=INFO
formatter=verbose
args=('/app/logs/celery.log', 'a', 10485760, 5, 'utf-8')

[handler_gunicorn_access]
class=handlers.RotatingFileHandler
level=INFO
formatter=verbose
args=('/app/logs/gunicorn-access.log', 'a', 10485760, 5, 'utf-8')

[handler_gunicorn_error]
class=handlers.RotatingFileHandler
level=ERROR
formatter=verbose
args=('/app/logs/gunicorn-error.log', 'a', 10485760, 5, 'utf-8')

[handler_syslog]
class=handlers.SysLogHandler
level=INFO
formatter=syslog
args=('/dev/log',)

# =============================================================================
# Formatters Configuration
# =============================================================================

[formatter_verbose]
format=%(asctime)s [%(levelname)s] %(name)s: %(message)s (%(filename)s:%(lineno)d)
datefmt=%Y-%m-%d %H:%M:%S

[formatter_simple]
format=%(levelname)s %(message)s

[formatter_json]
format={"timestamp": "%(asctime)s", "level": "%(levelname)s", "logger": "%(name)s", "message": "%(message)s", "module": "%(module)s", "function": "%(funcName)s", "line": %(lineno)d}
datefmt=%Y-%m-%dT%H:%M:%S

[formatter_syslog]
format=adtlas[%(process)d]: %(levelname)s %(name)s: %(message)s