Skip to content

Commit 7d9b5b6

Browse files
authored
Merge pull request rails#48088 from skipkayhil/hm-log-sub-docs
More Subscriber and LogSubscriber doc uniformity [ci skip]
2 parents 2bfb656 + 2384eb4 commit 7d9b5b6

File tree

2 files changed

+15
-20
lines changed

2 files changed

+15
-20
lines changed

activesupport/lib/active_support/log_subscriber.rb

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,20 @@ module ActiveSupport
1818
#
1919
# module ActiveRecord
2020
# class LogSubscriber < ActiveSupport::LogSubscriber
21+
# attach_to :active_record
22+
#
2123
# def sql(event)
2224
# info "#{event.payload[:name]} (#{event.duration}) #{event.payload[:sql]}"
2325
# end
2426
# end
2527
# end
2628
#
27-
# And it's finally registered as:
28-
#
29-
# ActiveRecord::LogSubscriber.attach_to :active_record
30-
#
31-
# Since we need to know all instance methods before attaching the log
32-
# subscriber, the line above should be called after your
33-
# <tt>ActiveRecord::LogSubscriber</tt> definition.
34-
#
35-
# A logger also needs to be set with <tt>ActiveRecord::LogSubscriber.logger=</tt>.
36-
# This is assigned automatically in a Rails environment.
29+
# ActiveRecord::LogSubscriber.logger must be set as well, but it is assigned
30+
# automatically in a \Rails environment.
3731
#
38-
# After configured, whenever a <tt>"sql.active_record"</tt> notification is published,
39-
# it will properly dispatch the event
40-
# (<tt>ActiveSupport::Notifications::Event</tt>) to the sql method.
32+
# After configured, whenever a <tt>"sql.active_record"</tt> notification is
33+
# published, it will properly dispatch the event
34+
# (ActiveSupport::Notifications::Event) to the +sql+ method.
4135
#
4236
# Being an ActiveSupport::Notifications consumer,
4337
# <tt>ActiveSupport::LogSubscriber</tt> exposes a simple interface to check if
@@ -62,9 +56,10 @@ module ActiveSupport
6256
# end
6357
# end
6458
#
65-
# Log subscriber also has some helpers to deal with logging and automatically
66-
# flushes all logs when the request finishes
67-
# (via <tt>action_dispatch.callback</tt> notification) in a Rails environment.
59+
# <tt>ActiveSupport::LogSubscriber</tt> also has some helpers to deal with
60+
# logging. For example, ActiveSupport::LogSubscriber.flush_all! will ensure
61+
# that all logs are flushed, and it is called in Rails::Rack::Logger after a
62+
# request finishes.
6863
class LogSubscriber < Subscriber
6964
# Embed in a String to clear all previous ANSI sequences.
7065
CLEAR = ActiveSupport::Deprecation::DeprecatedObjectProxy.new("\e[0m", "CLEAR is deprecated! Use MODES[:clear] instead.", ActiveSupport.deprecator)

activesupport/lib/active_support/subscriber.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
module ActiveSupport
66
# = Active Support \Subscriber
77
#
8-
# ActiveSupport::Subscriber is an object set to consume
8+
# <tt>ActiveSupport::Subscriber</tt> is an object set to consume
99
# ActiveSupport::Notifications. The subscriber dispatches notifications to
1010
# a registered object based on its given namespace.
1111
#
@@ -22,9 +22,9 @@ module ActiveSupport
2222
# end
2323
# end
2424
#
25-
# After configured, whenever a "sql.active_record" notification is published,
26-
# it will properly dispatch the event (ActiveSupport::Notifications::Event) to
27-
# the +sql+ method.
25+
# After configured, whenever a <tt>"sql.active_record"</tt> notification is
26+
# published, it will properly dispatch the event
27+
# (ActiveSupport::Notifications::Event) to the +sql+ method.
2828
#
2929
# We can detach a subscriber as well:
3030
#

0 commit comments

Comments
 (0)