0.0
No commit activity in last 3 years
No release in over 3 years
Provides a single interface for logging so that applications do not need to be aware of NewRelic, Rollbar, or whatever else.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

Tablexi::Logger

Gem Version Circle CI

Standardized logging for Table XI applications.

The default behavior will log to Rails.logger or fallback to ::Logger.new($stdout) if Rails is not available. If Rollbar or NewRelic are available, logging will also send events to the available service for log levels error or higher.

Usage

Basic usage looks like this:

Tablexi.logger.warn "Missing configuration, using default"
Tablexi.logger.error "Bad Things Happened"
Tablexi.logger.error "Bad Request", request: request
Tablexi.logger.error "Request Timeout", metric: :timeout_error

You may also assign the logger, for example configuring a null logger would look like this:

Tablexi.logger = Tablexi::Logger.new # not configured with any handlers, so does nothing

Extending Functionality

Options Filtering

Applications may wish to modify the options passed to error handlers - for example a Tablexi::Logger::OptionFilter::HumanizeRequest is provided by default, which takes any options[:request] value and splits out the interesting parts such as request method and body, and excludes the spammy parts such as headers.

Option filters may be configured via the Tablexi::Logger#option_filters array with a callable:

Tablexi.logger.option_filters << ->(options) { options.delete(:password) }  

Registering logging handlers

Custom logging handlers implement callable and may be registered by log level (e.g. :debug):

Tablexi.logger.handlers[:debug] << ->(error, options) { puts [error, options].join("\n") }

# Or to register multiple severities at once
Tablexi.logger.handle [:debug, :warn, :info] do |*args|
  puts args.join("\n")
end

License

The gem is available as open source under the terms of the MIT License.