An open API service indexing awesome lists of open source software.

https://github.com/umbrellio/log_sweeper

A simple module for cleaning up log directories.
https://github.com/umbrellio/log_sweeper

Last synced: about 1 year ago
JSON representation

A simple module for cleaning up log directories.

Awesome Lists containing this project

README

          

# LogSweeper   [![Gem Version](https://badge.fury.io/rb/log_sweeper.svg)](https://badge.fury.io/rb/log_sweeper) [![Build Status](https://travis-ci.org/umbrellio/log_sweeper.svg?branch=master)](https://travis-ci.org/umbrellio/log_sweeper) [![Coverage Status](https://coveralls.io/repos/github/umbrellio/log_sweeper/badge.svg?branch=master)](https://coveralls.io/github/umbrellio/log_sweeper?branch=master)

`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

```ruby
# 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](https://github.com/javan/whenever) gem with similar config in `schedule.rb` file:

```ruby
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