diff --git a/actioncable/app/javascript/action_cable/logger.js b/actioncable/app/javascript/action_cable/logger.js index ef4661ead1..c73f5bd542 100644 --- a/actioncable/app/javascript/action_cable/logger.js +++ b/actioncable/app/javascript/action_cable/logger.js @@ -1,5 +1,17 @@ import adapters from "./adapters" +// The logger is disabled by default. You can enable it with: +// +// ActionCable.logger.enabled = true +// +// Example: +// +// import * as ActionCable from '@rails/actioncable' +// +// ActionCable.logger.enabled = true +// ActionCable.logger.log('Connection Established.') +// + export default { log(...messages) { if (this.enabled) { diff --git a/guides/source/action_cable_overview.md b/guides/source/action_cable_overview.md index 3dc75bcfa6..cac3cf48a2 100644 --- a/guides/source/action_cable_overview.md +++ b/guides/source/action_cable_overview.md @@ -754,6 +754,17 @@ connections as you have workers. The default worker pool size is set to 4, so that means you have to make at least 4 database connections available. You can change that in `config/database.yml` through the `pool` attribute. +### Client side logging + +Client side logging is disabled by default. You can enable this by setting the `ActionCable.logger.enabled` to true. + +```ruby +import * as ActionCable from '@rails/actioncable' + +ActionCable.logger.enabled = true +``` + + ### Other Configurations The other common option to configure is the log tags applied to the