crystal-simplog
SimpLog
Crystal language shard which provides a file-based Log::Backend that supports automatic log file rotation, compression, and purging.
Installation
-
Add the dependency to your
shard.yml:dependencies: simplog: github: lachlan/crystal-simplog -
Run
shards install
Usage
require "simplog"
# create a new log backend
backend = SimpLog::FileBackend.new
# defaults to retaining log files forever, however log purging can be enabled
# by setting the file retention as follows:
backend.delete_after = 14.days
# defaults to compressing logs older than 7 days, however this can be changed
# as follows:
backend.compress_after = 2.days
# setup logging to use simplog backend
Log.setup_from_env(backend: backend)
# then log messages as required...
Log.info { "Hello World" } # => writes to log file ./log/<executable>.log
Contributing
- Fork it (https://github.com/lachlan/crystal-simplog/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- Lachlan Dowding - creator and maintainer
Repository
crystal-simplog
Owner
Statistic
- 1
- 0
- 0
- 2
- 0
- 7 days ago
- January 11, 2024
License
MIT License
Links
Synced at
Tue, 16 Jun 2026 01:03:47 GMT
Languages