Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Ruby logging library that provides the ability to add class/module specific filters.
This README provides a brief overview of Hatchet, see the main site for more complete documentation and tutorials.
Add this line to your application's Gemfile:
gem 'hatchet'
And then execute:
$ bundle
Or install it yourself as:
$ gem install hatchet
To use the logger you must add it to your classes as a mixin or use it to extend
your modules. Then you can call the logger through the methods log
and
logger
. They are aliases for the same method to ease migration.
class Foo
include Hatchet
def self.class_work
log.info { 'Doing some class work' }
end
def work
log.info { 'Doing some work' }
end
def dangerous_work
log.info { 'Attempting dangerous work' }
attempt_dangerous_work
log.info { 'Dangerous work complete' }
true
rescue => e
log.error "Dangerous work failed - #{e.message}", e
false
end
end
module Bar
include Hatchet
def self.work
log.info { 'Doing some module work' }
end
def work
log.info { 'Doing some mixin work' }
end
end
Hatchet.configure do |config|
# Set the level to use unless overridden (defaults to :info)
config.level :info
# Set the level for a specific class/module and its children
config.level :debug, 'Namespace::Something::Nested'
# Add as many appenders as you like
config.appenders << Hatchet::LoggerAppender.new do |appender|
# Set the logger that this is wrapping (required)
appender.logger = Logger.new('log/test.log')
end
end
Use the standard configuration method but also register Hatchet as a helper where appropriate:
register Hatchet
Note that you may have to use the log
alias as Sinatra already has a logger
method.
Hatchet includes a Railtie that is loaded automatically and wraps the
Rails.logger
. The Hatchet configuration object is available through
config.hatchet
within your standard configuration files for fine-tuning your
Hatchet configuration.
To make it so your log calls are scoped to your controllers you also need to add
Hatchet to your ApplicationController
:
class ApplicationController < ActionController::Base
include Hatchet
end
You could include it in your models so that each of those has its own logging context too.
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)All pull requests should come complete with tests when appropriate and should follow the existing style which is best described in Github's Ruby style guide.
FAQs
Unknown package
We found that hatchet 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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.