logcr

Version, currently 0.1.11 version
  • 0.1.1latestAug 10, 2020

github.com/OisinA/logcr

A simple structured logging library for Crystal. Supports either readable output or JSON.

1 stars
0 dependents
License: MIT

Installation

# Add this to your shard.yml
dependencies:
  logcr:
    github: OisinA/logcr
    version: ~> 0.1.1

Then run:

shards install

shard.yml

Crystal
0.34.0
License
MIT
Author
OisinA

Dependencies

This version declares no dependencies.

README

LogCR

A simple structured logging library for Crystal. Supports either readable output or JSON.

Usage

logger = LogCR::Logger.new("test", :info, :simple)
logger.with_fields({"key"=>"value"}).info("out")
2020-08-10 22:33:19 +01:00 [test] [INFO] out
        key => value

Different Log Levels

LogCR::Logger.new("test", :debug, :simple)
LogCR::Logger.new("test", :info, :simple)
LogCR::Logger.new("test", :warn, :simple)
LogCR::Logger.new("test", :error, :simple)

JSON Output

logger = LogCR::Logger.new("test", :info, :json)
logger.with_fields({"key"=>"value"}).info("out")
{"msg":"out","_level":"info","_line":"7","_file":"/home/Projects/logcr/spec/logcr_spec.cr","key":"value"}

Contributing

  1. Fork it (https://github.com/OisinA/logcr/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

  • OisinA - creator and maintainer