awesome-logger

Simple and flexible logger
HEAD Latest release released

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

  1. Fork it (https://github.com/tbrand/awesome-logger/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

  • tbrand Taichiro Suzuki - creator, maintainer
awesome-logger:
  github: tbrand/awesome-logger
  
License MIT
Crystal 0.25.0

Authors

Dependencies 0

Development Dependencies 0

Dependents 0

Last synced .
search fire star recently