Sha256: a6c7ad2a31b4fa8139e8c65eb93d64ca781cc032660b7d43d7003f425277e127
Contents?: true
Size: 1.19 KB
Versions: 3
Compression:
Stored size: 1.19 KB
Contents
# MicroLogger [![[travis]](https://travis-ci.org/janlelis/micrologger.png)](https://travis-ci.org/janlelis/micrologger) A minimal logger based on [MicroEvent](https://github.com/janlelis/microevent.rb). ## Setup Add to your `Gemfile` ```ruby gem 'micrologger' ``` ## How to Use It A new logger has to be configured what should be done on log events using handler procs. There are two default handlers for logging to STDOUT/STDERR included: ```ruby $logger = MicroLogger.new $logger.register :info, :stdout $logger.register :fatal, :stderr $logger.log "debug" # STDOUT: debug $logger.log "error", :fatal # STDERR: error ``` For any andvanced or customized behaviour, you will need to register your own blocks/procs: ### Example: Log to File ```ruby $logger = MicroLogger.new $logger.register :warn, :stderr $logger.register :warn do |message, meta| File.open("logfile.#{meta[:level]}.txt", "a"){ |f| f.puts "#{meta[:time]} | #{message}" } end $logger.log "hey", :warn # Will write to STDERR and logfile.warn.txt ``` Other ideas you could do: Send data to a remote endpoint, send emails, send to analytics... ## J-_-L Copyright (c) 2015 [Jan Lelis](http://janlelis.com). See MIT-LICENSE for details.
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
micrologger-0.1.2 | README.md |
micrologger-0.1.1 | README.md |
micrologger-0.1.0 | README.md |