Yell - Your Extensible Logging Library
Yell works and is tested with ruby 1.8.7, 1.9.x, jruby 1.8 and 1.9 mode, rubinius 1.8 and 1.9 as well as ree.
gem install yell
Or in your Gemfile:
On the basics, Yell works just like any other logging library. However, it tries to make your log mesages more readable. By default, it will format the given message as follows:
logger = Yell.new STDOUT logger.info "Hello World" #=> "2012-02-29T09:30:00+01:00 [ INFO] 65784 : Hello World" # ^ ^ ^ ^ # ISO8601 Timestamp Level Pid Message
When no arguments are given, Yell will check for
determine the filename from that.
Alternatively, you may define
ENV['YELL_ENV'] to set the filename. If neither
RACK_ENV is defined, 'development' will be the default. Also, if a
log directory exists, Yell will place the file there (only if you have not passed
a filename explicitly.
Naturally, you can pass a
:filename to Yell:
logger = Yell.new "yell.log"
Just like any other logging library, Yell allows you to define from which level onwarns you want to write your log message. here are some examples to show how you can combine those.
Example: Write from
logger = Yell.new STDOUT, :level => :info # write on :info, :warn, :error, :fatal
Example: Write on
logger - Yell.new STDOUT, :level => [:info, :error] # write on :info and :error only
Example: Write between :info and :error
logger = Yell.new STDOUT, :level => (:info..:error) # NOTE: The Range might only work with 1.9 compatible rubies!
There are more ways to set your logging level, please consult the wiki on that.
Yell comes with various adapters already build-in. Those are the mainly IO-based adapters for every day use. There are additional ones available as separate gems. Please consult the wiki on that - they are listed there.
The standard adapters are:
:stdout or STDOUT: Messages will be written to STDOUT
:stderr or STDERR: Messages will be written to STDERR
:file: Messages will be written to a file
:datefile: Messages will be written to a timestamped file
Here are some short examples on how to combine them:
Example: Notice messages go into
STDOUT and error messages into
logger = Yell.new do adapter STDOUT, :level => [:debug, :info, :warn] adapter STDERR, :level => [:error, :fatal] end
Example: Notice messages to into
application.log and error messages into
logger = Yell.new do adapter :file, 'application.log', :level => [:debug, :info, :warn] adapter :file, 'error.log', :level => [:error, :fatal] end
Example: Every log severity is handled by a separate adapter and we ignore
logger = Yell.new do level :warn # only start logging from :warn upwards adapter :stdout, :level => [:warn] adapter :datefile, 'error.log', :level => [:error] adapter :datefile, 'fatal.log', :level => [:fatal] end
You can find further examples and additional adapters in the wiki. or have a look into the examples folder.
Copyright © 2011-2012 Rudolf Schmidt, released under the MIT license