项目作者: guvencenanguvenal

项目描述 :
Katip is JSONBase Logger for Crystal
高级语言: Crystal
项目地址: git://github.com/guvencenanguvenal/katip.git
创建时间: 2017-05-02T17:08:22Z
项目社区:https://github.com/guvencenanguvenal/katip

开源协议:MIT License

下载


katip

Katip is Logger for Crystal

Installation

Add this to your application’s shard.yml:

  1. dependencies:
  2. katip:
  3. github: guvencenanguvenal/katip

Usage

  1. require "katip"

Create your logger variable and configure it.

  1. logger = Katip::Logger.new
  2. logger.configure do |config|
  3. config.loglevel = Katip::LogLevel::DEBUG
  4. config.logclassification = Katip::LogClassification::DATE_DAY
  5. config.path = "src/katip/logfiles"
  6. #### if you want to fill project's information
  7. config.info.description = "This is project description."
  8. config.info.project = "Module or project name."
  9. config.info.version = VERSION # project version
  10. end

And basic log it!

  1. logger.debug("Debug mode is on!")
  2. logger.info("Information! This is log.")
  3. logger.warn("Warning! Please control your code.")
  4. logger.error("Error! Please fix and re-compile it!")
  5. logger.fatal("Fatal! OH NO!")

if you want log detail, you can use this methods.

  1. logger.debug("Debug mode is on!", self, YourExceptionName)
  2. logger.info("Information! This is log.", self, YourExceptionName)
  3. logger.warn("Warning! Please control your code.", self, YourExceptionName)
  4. logger.error("Error! Please fix and re-compile it!", self, YourExceptionName)
  5. logger.fatal("Fatal! OH NO!", self, YourExceptionName)

JSON Output

Please do not edit manual JSON log files!

  1. {
  2. "katip":"0.1.0",
  3. "info":{
  4. "description":"",
  5. "project":"",
  6. "version":""},
  7. "errors":[
  8. { "date":"2017-05-07 00:24:57 +0300",
  9. "class":"Class",
  10. "message":"Debug mode is on!",
  11. "exception_type":"Katip::NotSetException",
  12. "exception_message":"Not Init",
  13. "log_level":"DEBUG"
  14. }
  15. ]
  16. }

View Your Logs

You can use katipviewer.html to control your logs.

Open katipviewer.html on local machine.

Choose your log json file.

Click Read JSON Log button.

Contributing

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