Class: ActiveSupport::EventReporter::LogSubscriber
| Relationships & Source Files | |
| Extension / Inclusion / Inheritance Descendants | |
|
Subclasses:
|
|
| Super Chains via Extension / Inclusion / Inheritance | |
|
Instance Chain:
|
|
| Inherits: | Object |
| Defined in: | activesupport/lib/active_support/event_reporter/log_subscriber.rb |
Constant Summary
-
LOG_LEVELS =
# File 'activesupport/lib/active_support/event_reporter/log_subscriber.rb', line 12[:debug, :info, :warn, :error].freeze
-
LOG_LEVEL_PREDICATES =
Internal use only
# File 'activesupport/lib/active_support/event_reporter/log_subscriber.rb', line 13LOG_LEVELS.index_with { |level| :"#{level}?" }.freeze
::ActiveSupport::ColorizeLogging - Included
BLACK, BLUE, CYAN, GREEN, MAGENTA, MODES, RED, WHITE, YELLOW
Class Attribute Summary
- .logger rw
- .logger=(value) rw
- .namespace rw
- .log_levels rw Internal use only
- .log_levels? ⇒ Boolean rw Internal use only
Class Method Summary
Instance Attribute Summary
- #log_levels rw Internal use only
- #log_levels? ⇒ Boolean rw Internal use only
Instance Method Summary
- #emit(event) Internal use only
- #logger Internal use only
- #log_level_satisfied?(event_method) ⇒ Boolean private Internal use only
- #namespace private Internal use only
::ActiveSupport::ColorizeLogging - Included
| #color | Set color by using a symbol or one of the defined constants. |
| #colorize_logging, #debug, #error, #fatal, #info, #mode_from, #unknown, #warn | |
Class Attribute Details
.log_levels (rw)
This method is for internal use only.
[ GitHub ]
# File 'activesupport/lib/active_support/event_reporter/log_subscriber.rb', line 39
class_attribute :log_levels, default: {}.freeze # :nodoc:
.log_levels? ⇒ Boolean (rw)
This method is for internal use only.
[ GitHub ]
# File 'activesupport/lib/active_support/event_reporter/log_subscriber.rb', line 39
class_attribute :log_levels, default: {}.freeze # :nodoc:
.logger (rw)
[ GitHub ]# File 'activesupport/lib/active_support/event_reporter/log_subscriber.rb', line 20
def logger @logger || default_logger end
.logger=(value) (rw)
[ GitHub ]# File 'activesupport/lib/active_support/event_reporter/log_subscriber.rb', line 28
attr_writer :logger
.namespace (rw)
[ GitHub ]# File 'activesupport/lib/active_support/event_reporter/log_subscriber.rb', line 29
attr_accessor :namespace
Class Method Details
.default_logger
# File 'activesupport/lib/active_support/event_reporter/log_subscriber.rb', line 24
def default_logger raise NotImplementedError end
.event_log_level(method_name, level)
[ GitHub ]# File 'activesupport/lib/active_support/event_reporter/log_subscriber.rb', line 16
def event_log_level(method_name, level) self.log_levels = log_levels.merge(method_name.to_s => level).freeze end
.subscription_filter
[ GitHub ]# File 'activesupport/lib/active_support/event_reporter/log_subscriber.rb', line 31
def subscription_filter prefix = "#{namespace}.".freeze proc do |event| event[:name].start_with?(prefix) end end
Instance Attribute Details
#log_levels (rw)
This method is for internal use only.
[ GitHub ]
# File 'activesupport/lib/active_support/event_reporter/log_subscriber.rb', line 39
class_attribute :log_levels, default: {}.freeze # :nodoc:
#log_levels? ⇒ Boolean (rw)
This method is for internal use only.
[ GitHub ]
# File 'activesupport/lib/active_support/event_reporter/log_subscriber.rb', line 39
class_attribute :log_levels, default: {}.freeze # :nodoc:
Instance Method Details
#emit(event)
This method is for internal use only.
[ GitHub ]
# File 'activesupport/lib/active_support/event_reporter/log_subscriber.rb', line 41
def emit(event) return unless logger name = event[:name] event_method = name[name.index(".") + 1, name.length] public_send(event_method, event) if log_level_satisfied?(event_method) end
#log_level_satisfied?(event_method) ⇒ Boolean (private)
This method is for internal use only.
# File 'activesupport/lib/active_support/event_reporter/log_subscriber.rb', line 58
def log_level_satisfied?(event_method) predicate = LOG_LEVEL_PREDICATES[log_levels[event_method]] return false unless predicate logger.public_send(predicate) end
#logger
This method is for internal use only.
[ GitHub ]
# File 'activesupport/lib/active_support/event_reporter/log_subscriber.rb', line 49
def logger self.class.logger end
#namespace (private)
This method is for internal use only.
[ GitHub ]
# File 'activesupport/lib/active_support/event_reporter/log_subscriber.rb', line 54
def namespace self.class.namespace end