/charm-layer-logrotate

Adding logrotate functionality to reactive charms

Primary LanguagePythonApache License 2.0Apache-2.0

Overview

Apache 2.0 License

This base layer provides a function to add logrotate support to any reactive charm.

Usage

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)