Awesome Logger
Awesome Logger is SIMPLE and FLEXIBLE logger for Crystal applications.**
:star: It aims to be a standard logger in Crystal world. :star:
- :ribbon: Cool colorized output
- :trophy: Customizable handler interface (e.g. Slack notification)
- :gem: Control log level on code or env var.
Installation
Add this to your application's shard.yml
:
dependencies:
awesome-logger:
github: tbrand/awesome-logger
Usage
require "awesome-logger"
See example/
for basic usages.
Logger.debug("this is a debug message")
# Logger.d("your message") for short
Control log level
You can set log level by
# The level is one of :debug, :info, :warning, :error or :fatal
Logger.set_level(:debug)
You can override the level by set env var of CR_LOG_LEVEL
.
# The level is one of DEBUG, INFO, WARNING, ERROR or FATAL
> export CR_LOG_LEVEL=DEBUG
The default log level is :info
.
Custom handler
You can define your custom handler for the logger.
This is useful when you want to hook some logs. (e.g. error notification)
For the slack notification, the example code is at example/slack_notification.cr
.
Contributing
- Fork it (https://github.com/tbrand/awesome-logger/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
- tbrand Taichiro Suzuki - creator, maintainer