LogSweeper   Gem Version Build Status Coverage Status

LogSweeper is a simple module for cleaning up log directories.

It is designed to be used with Ruby logger rotation. By default, it will remove all log files older than 10 days and will gzip all log files that look like rotated log files. For example, production.log.20190228 will be gzipped and replaced with production.log.20190228.gz. It logs what it's doing using the provided logger which defaults to STDOUT logger.

Installation

Simply add gem "log_sweeper" to your Gemfile.

Examples

  # Just use the defaults
  LogSweeper.run("log")

  # Customize logs lifetime and logger
  LogSweeper.run("log", logs_lifetime_days_count: 5, logger: Logger.new("/path/to/file.log"))

  # In case you don't want any logging and deleting any logs
  LogSweeper.run("log", logs_lifetime_days_count: Float::INFINITY, logger: Logger.new(nil))

The best way to use this module is to run it via cron, for example you can use whenever gem with similar config in schedule.rb file:

every 1.hour do
  runner "LogSweeper.run('log')"
end

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/umbrellio/log_sweeper.

License

Released under MIT License.

Authors

Created by Yuri Smirnov.

Supported by Umbrellio