#
# logrotate doesn't support pattern precedence, so they have to be explicit
#
# logs that should be deleted every day
/var/log/mythtv/mythcommflag.*.*.log
/var/log/mythtv/mythpreviewgen.*.*.log
/var/log/mythtv/mythtranscode.*.*.log
{
    daily
    rotate 0
    nocreate
    missingok
    ifempty
}

# all other non-backend logs are kept for a week
/var/log/mythtv/mythfilldatabase*.*.*.log
/var/log/mythtv/mythmetadatalookup*.*.*.log
{
    weekly
    rotate 0
    nocreate
    missingok
    ifempty
}

# backend log: keep for 4 weeks & compress
/var/log/mythtv/mythbackend.*.*.log {
    weekly
    rotate 4
    nocreate
    missingok
    ifempty
    compress
    compresscmd /usr/bin/bzip2
    uncompresscmd /usr/bin/bunzip2
    compressext .bz2
    postrotate
        /bin/systemctl kill mythbackend.service --signal=HUP --kill-who=main 2>/dev/null || true
        # general cleanup after 4 weeks of anything we might have missed
        find /var/log/mythtv -type f -mtime +30 -delete
    endscript
}
