# Laravel Application Log Rotation Configuration
# Place this file in /etc/logrotate.d/laravel-insurance-admin

/var/www/insurance.admin/storage/logs/*.log {
    daily
    missingok
    rotate 30
    compress
    delaycompress
    notifempty
    create 644 www-data www-data
    postrotate
        if [ -f /var/run/nginx.pid ]; then
            kill -USR1 `cat /var/run/nginx.pid`
        fi
        if [ -f /var/run/php/php8.1-fpm.pid ]; then
            kill -USR1 `cat /var/run/php/php8.1-fpm.pid`
        fi
    endscript
}

# Nginx Access Logs
/var/log/nginx/access.log {
    daily
    missingok
    rotate 30
    compress
    delaycompress
    notifempty
    create 644 www-data adm
    postrotate
        if [ -f /var/run/nginx.pid ]; then
            kill -USR1 `cat /var/run/nginx.pid`
        fi
    endscript
}

# Nginx Error Logs
/var/log/nginx/error.log {
    daily
    missingok
    rotate 30
    compress
    delaycompress
    notifempty
    create 644 www-data adm
    postrotate
        if [ -f /var/run/nginx.pid ]; then
            kill -USR1 `cat /var/run/nginx.pid`
        fi
    endscript
}

# PHP-FPM Logs
/var/log/php8.1-fpm.log {
    daily
    missingok
    rotate 30
    compress
    delaycompress
    notifempty
    create 644 www-data adm
    postrotate
        if [ -f /var/run/php/php8.1-fpm.pid ]; then
            kill -USR1 `cat /var/run/php/php8.1-fpm.pid`
        fi
    endscript
}

# MySQL Logs
/var/log/mysql/error.log {
    daily
    missingok
    rotate 30
    compress
    delaycompress
    notifempty
    create 644 mysql adm
    postrotate
        if [ -f /var/run/mysqld/mysqld.pid ]; then
            kill -USR1 `cat /var/run/mysqld/mysqld.pid`
        fi
    endscript
}

# Application Specific Logs
/var/www/insurance.admin/storage/logs/laravel.log {
    daily
    missingok
    rotate 30
    compress
    delaycompress
    notifempty
    create 644 www-data www-data
    copytruncate
}

/var/www/insurance.admin/storage/logs/queue.log {
    daily
    missingok
    rotate 30
    compress
    delaycompress
    notifempty
    create 644 www-data www-data
    copytruncate
}

/var/www/insurance.admin/storage/logs/schedule.log {
    daily
    missingok
    rotate 30
    compress
    delaycompress
    notifempty
    create 644 www-data www-data
    copytruncate
}

# Debug Logs
/var/www/insurance.admin/storage/logs/debug.log {
    daily
    missingok
    rotate 7
    compress
    delaycompress
    notifempty
    create 644 www-data www-data
    copytruncate
}

# API Logs
/var/www/insurance.admin/storage/logs/api.log {
    daily
    missingok
    rotate 30
    compress
    delaycompress
    notifempty
    create 644 www-data www-data
    copytruncate
}

# Error Logs
/var/www/insurance.admin/storage/logs/error.log {
    daily
    missingok
    rotate 30
    compress
    delaycompress
    notifempty
    create 644 www-data www-data
    copytruncate
}

# Custom Application Logs
/var/www/insurance.admin/storage/logs/insurance.log {
    daily
    missingok
    rotate 30
    compress
    delaycompress
    notifempty
    create 644 www-data www-data
    copytruncate
}

/var/www/insurance.admin/storage/logs/client.log {
    daily
    missingok
    rotate 30
    compress
    delaycompress
    notifempty
    create 644 www-data www-data
    copytruncate
}

/var/www/insurance.admin/storage/logs/provider.log {
    daily
    missingok
    rotate 30
    compress
    delaycompress
    notifempty
    create 644 www-data www-data
    copytruncate
}
