From c25b77fb6bf513e47f9a800aab5c401404fe554a Mon Sep 17 00:00:00 2001 From: Kartikey Tanna Date: Sun, 3 May 2020 11:52:06 +0530 Subject: [PATCH 1/3] Added docs for client-side logger --- actioncable/app/javascript/action_cable/logger.js | 5 +++++ guides/source/action_cable_overview.md | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/actioncable/app/javascript/action_cable/logger.js b/actioncable/app/javascript/action_cable/logger.js index ef4661ead1..f4b99390c1 100644 --- a/actioncable/app/javascript/action_cable/logger.js +++ b/actioncable/app/javascript/action_cable/logger.js @@ -1,5 +1,10 @@ import adapters from "./adapters" +// The logger can be enabled with: +// +// ActionCable.logger.enabled = true +// + 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..f456948c75 100644 --- a/guides/source/action_cable_overview.md +++ b/guides/source/action_cable_overview.md @@ -771,6 +771,14 @@ config.action_cable.log_tags = [ For a full list of all configuration options, see the `ActionCable::Server::Configuration` class. +Client-side logs can be enabled with the following: + +```ruby +import * as ActionCable from '@rails/actioncable' + +ActionCable.logger.enabled = true +``` + ## Running Standalone Cable Servers ### In App From bc3cf14c8cbc2ca9fd309a8fc04f942f48048e3c Mon Sep 17 00:00:00 2001 From: Kartikey Tanna Date: Mon, 6 Jul 2020 23:32:31 +0530 Subject: [PATCH 2/3] Created a section for ActionCable client side logger --- guides/source/action_cable_overview.md | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/guides/source/action_cable_overview.md b/guides/source/action_cable_overview.md index f456948c75..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 @@ -771,14 +782,6 @@ config.action_cable.log_tags = [ For a full list of all configuration options, see the `ActionCable::Server::Configuration` class. -Client-side logs can be enabled with the following: - -```ruby -import * as ActionCable from '@rails/actioncable' - -ActionCable.logger.enabled = true -``` - ## Running Standalone Cable Servers ### In App From e0ec24e3c0b9dfd7bdf6d99e486e140dd400ed16 Mon Sep 17 00:00:00 2001 From: Kartikey Tanna Date: Mon, 6 Jul 2020 23:32:55 +0530 Subject: [PATCH 3/3] Added an example of logging --- actioncable/app/javascript/action_cable/logger.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/actioncable/app/javascript/action_cable/logger.js b/actioncable/app/javascript/action_cable/logger.js index f4b99390c1..c73f5bd542 100644 --- a/actioncable/app/javascript/action_cable/logger.js +++ b/actioncable/app/javascript/action_cable/logger.js @@ -1,9 +1,16 @@ import adapters from "./adapters" -// The logger can be enabled with: +// 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) {