Sha256: 44c17ab7c7cfe635091be57853fa9b2d65d783ac096155152ddcf247ef548f43

Contents?: true

Size: 959 Bytes

Versions: 4

Compression:

Stored size: 959 Bytes

Contents

%w( formatter
    railtie
    log_subscribers/base
    log_subscribers/action_controller
    log_subscribers/action_dispatch
    log_subscribers/action_mailer
    log_subscribers/active_job
    middleware/request_logger
    middleware/routing_error_catcher
    extensions/action_controller_helper 
    extensions/active_support_subscriber
  ).each do |fn|
  require_relative "log_sanity/#{fn}"
end

ActionController::Base.include LogSanity::Extensions::ActionControllerHelper
ActionController::API.include  LogSanity::Extensions::ActionControllerHelper if defined?(ActionController::API)
if Rails.version < '6'
  ActiveSupport::Subscriber.include LogSanity::Extensions::ActiveSupportSubscriber
end

module LogSanity
  module_function

  def fields
    Thread.current[:logsanity_fields] || reset_fields
  end

  def reset_fields
    Thread.current[:logsanity_fields] = {}.with_indifferent_access
  end

  def log(key, val)
    fields[key.to_s] = val
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
log_sanity-1.1.1 lib/log_sanity.rb
log_sanity-1.1.0 lib/log_sanity.rb
log_sanity-1.0.0 lib/log_sanity.rb
log_sanity-0.2.5 lib/log_sanity.rb