This base layer provides a function to add logrotate support to any reactive charm.
Declarative via layer.yaml
options:
logrotate:
/var/log/foobar.log:
- copytruncate
- rotate 5
- size 100k
In your charm code
from charms.layer import logrotate
@when(logrotate.installed, ...)
def setup_logrotate():
logrotate_opts = {
/var/log/foobar.log: [
'copytruncate',
'rotate 5',
'size 100k',
]
}
logrotate.configure(logrotate_opts)