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.
- Host: GitHub
- URL: https://github.com/umbrellio/log_sweeper
- Owner: umbrellio
- License: mit
- Created: 2019-02-03T08:26:09.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-08-19T19:54:19.000Z (almost 7 years ago)
- Last Synced: 2024-10-13T12:27:02.174Z (over 1 year ago)
- Language: Ruby
- Homepage:
- Size: 20.5 KB
- Stars: 2
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# LogSweeper [](https://badge.fury.io/rb/log_sweeper) [](https://travis-ci.org/umbrellio/log_sweeper) [](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.