0.0
Low commit activity in last 3 years
No release in over a year
A minimal logger based on MicroEvent.rb
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 0.9, < 3.0
 Project Readme

MicroLogger [version] [CI]

A minimal logger based on MicroEvent.

Setup

Add to your Gemfile

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:

$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

$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. See MIT-LICENSE for details.