Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Yell - Your Extensible Logging Library is a comprehensive logging replacement for Ruby.
Yell works and its test suite currently runs on:
If you want to conveniently use Yell with Rails, then head over to yell-rails. You'll find all the documentation in this repository, though.
System wide:
gem install yell
Or in your Gemfile:
gem "yell"
On the basics, you can use Yell just like any other logging library with a more sophisticated message formatter.
logger = Yell.new STDOUT
logger.info "Hello World"
#=> "2012-02-29T09:30:00+01:00 [ INFO] 65784 : Hello World"
# ^ ^ ^ ^
# ISO8601 Timestamp Level Pid Message
The strength of Yell, however, comes when using multiple adapters. The already built-in ones are IO-based and require no further configuration. Also, there are additional ones available as separate gems. Please consult the wiki on that - they are listed there.
The standard adapters are:
:stdout
: Messages will be written to STDOUT
: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:
STDOUT
and error messages into STDERR
logger = Yell.new do |l|
l.adapter STDOUT, level: [:debug, :info, :warn]
l.adapter STDERR, level: [:error, :fatal]
end
We setup a logger that starts passing messages at the :info
level. Severities
below :error
go into the 'production.log', whereas anything higher is written
into the 'error.log'.
logger = Yell.new do |l|
l.level = 'gte.info' # will only pass :info and above to the adapters
l.adapter :datefile, 'production.log', level: 'lte.warn' # anything lower or equal to :warn
l.adapter :datefile, 'error.log', level: 'gte.error' # anything greater or equal to :error
end
When deploying to Heroku, the "rails_log_stdout" gem gets injected to your Rails project. Yell does not need that when properly configured (see yell-rails for a more convenient integration with Rails).
logger = Yell.new do |l|
l.level = 'gte.info'
l.adapter :stdout, level: 'lte.warn'
l.adapter :stderr, level: 'gte.error'
end
One of the really nice features of Log4r is its repository. The following example is taken from the official Log4r documentation.
require 'log4r'
include Log4r
# create a logger named 'mylog' that logs to stdout
mylog = Logger.new 'mylog'
mylog.outputters = Outputter.stdout
# later in the code, you can get the logger back
Logger['mylog']
With Yell you can do the same thing with less:
require 'yell'
# create a logger named 'mylog' that logs to stdout
Yell.new :stdout, name: 'mylog'
# later in the code, you can get the logger back
Yell['mylog']
There is no need to define outputters separately and you don't have to taint you global namespace with Yell's subclasses.
Yell comes with a simple module: +Yell::Loggable+. Simply include this in a class and you are good to go.
# Before you can use it, you will need to define a logger and
# provide it with the `:name` of your class.
Yell.new :stdout, name: 'Foo'
class Foo
include Yell::Loggable
end
# Now you can log
Foo.logger.info "Hello World"
Foo.new.logger.info "Hello World"
It even works with class inheritance:
# Given the above example, we inherit from Foo
class Bar < Foo
end
# The logger will fallback to the Foo superclass
Bar.logger.info "Hello World"
Bar.new.logger.info "Hello World"
Derived from the example above, simply do the following.
# Define a logger and pass `Object` as name. Internally, Yell adds this
# logger to the repository where you can access it later on.
Yell.new :stdout, name: Object
# Enable logging for the class that (almost) every Ruby class inherits from
Object.send :include, Yell::Loggable
# now you are good to go... from wherever you are
logger.info "Hello from anything"
Integer.logger.info "Hello from Integer"
In case you woul like to suppress certain log messages, you may define silencers with Yell. Use this to get control of a noisy log environment. For instance, you can suppress logging messages that contain secure information or more simply, to skip information about serving your Rails assets. Provide a string or a regular expression of the message patterns you would like to exclude.
logger = Yell.new do |l|
l.silence /^Started GET "\/assets/
l.silence /^Served asset/
end
logger.debug 'Started GET "/assets/logo.png" for 127.0.0.1 at 2013-06-20 10:18:38 +0200'
logger.debug 'Served asset /logo.png - 304 Not Modified (0ms)'
How To: Setting The Log Level
How To: Formatting Log Messages
How To: Using Adapters
How To: The Datefile Adapter
How To: Different Adapters for Different Log Levels
Syslog
syslog-sd
Graylog2 (GELF)
Fluentd
How To: Writing Your Own Adapter
You can find further examples and additional adapters in the wiki. or have a look into the examples folder.
Copyright © 2011-current Rudolf Schmidt, released under the MIT license
FAQs
Unknown package
We found that yell demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.