Sha256: 9f7464f3c3c6a66d4c88b47036c471adf67dc7c6e55e89d7c007f1fa822cf868
Contents?: true
Size: 1.47 KB
Versions: 3
Compression:
Stored size: 1.47 KB
Contents
# frozen_string_literal: true require 'active_support/core_ext/string/inflections' require 'action_view/log_subscriber' require 'action_controller/log_subscriber' require 'action_mailer/log_subscriber' require 'active_storage/log_subscriber' require_relative 'logjoy/version' require_relative 'logjoy/log_subscribers/action_controller' module Logjoy class Error < StandardError; end module_function mattr_accessor :customizer, :filters self.filters = [] def custom_fields(event) return {} if customizer.nil? customizer.call(event) end def set_customizer(app) return unless enabled?(app) self.customizer = app.config.logjoy.customizer end def set_path_filters(app) return unless enabled?(app) self.filters = app.config.logjoy.filters || [] end REPLACE_SUBSCRIBERS = %i[action_controller].freeze DETACH_SUBSCRIBERS = %i[action_view action_mailer active_storage].freeze def detach_default_subscriber(app, component) return unless enabled?(app) default_subscriber(component).detach_from(component) end def attach_subscriber(app, component) return unless enabled?(app) logjoy_subscriber(component).attach_to(component) end def default_subscriber(component) "#{component.to_s.camelize}::LogSubscriber".constantize end def logjoy_subscriber(component) "Logjoy::LogSubscribers::#{component.to_s.camelize}".constantize end def enabled?(app) app.config.logjoy.enabled end end require 'logjoy/railtie'
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
logjoy-1.0.0 | lib/logjoy.rb |
logjoy-0.3.5 | lib/logjoy.rb |
logjoy-0.3.4 | lib/logjoy.rb |