Skip to content

Commit

Permalink
Add Action Cable section to Readme (#284)
Browse files Browse the repository at this point in the history
Add Action Cable section to Readme
  • Loading branch information
xlts authored and benlovell committed May 13, 2019
1 parent 407a7bc commit 04b3007
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ Thanks to the notification system that was introduced in Rails 3, replacing the
logging is easy. Lograge unhooks all subscriptions from
`ActionController::LogSubscriber` and `ActionView::LogSubscriber`, and hooks in
its own log subscription, but only listening for two events: `process_action`
and `redirect_to`. It makes sure that only subscriptions from those two classes
and `redirect_to` (in case of standard controller logs).
It makes sure that only subscriptions from those two classes
are removed. If you happened to hook in your own, they'll be safe.

Unfortunately, when a redirect is triggered by your application's code,
Expand Down Expand Up @@ -257,6 +258,23 @@ enabled by default.

There, a single line per request. Beautiful.

## Action Cable ##

Starting with version 0.11.0, Lograge introduced support for Action Cable logs.
This proved to be a particular challenge since the framework code is littered
with multiple (and seemingly random) logger calls in a number of internal classes.
In order to deal with it, the default Action Cable logger was silenced.
As a consequence, calling logger e.g. in user-defined `Connection` or `Channel`
classes has no effect - `Rails.logger` (or any other logger instance)
has to be used instead.

Additionally, while standard controller logs rely on `process_action` and `redirect_to`
instrumentations only, Action Cable messages are generated from multiple events:
`perform_action`, `subscribe`, `unsubscribe`, `connect`, and `disconnect`.
`perform_action` is the only one included in the actual Action Cable code and
others have been added by monkey patching [`ActionCable::Channel::Base`](https://github.com/roidrage/lograge/blob/master/lib/lograge/rails_ext/action_cable/channel/base.rb) and
[`ActionCable::Connection::Base`](https://github.com/roidrage/lograge/blob/master/lib/lograge/rails_ext/action_cable/connection/base.rb) classes.

## What it doesn't do ##

Lograge is opinionated, very opinionated. If the stuff below doesn't suit your
Expand Down

0 comments on commit 04b3007

Please sign in to comment.