Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update logging documentation #2035

Merged
merged 5 commits into from
Jan 31, 2017
Merged

Update logging documentation #2035

merged 5 commits into from
Jan 31, 2017

Conversation

msathieu
Copy link
Contributor

Include documentation on how to disable the logging.
#2029 @bf4

@mention-bot
Copy link

@msathieu, thanks for your PR! By analyzing the history of the files in this pull request, we identified @bf4 and @maurogeorge to be potential reviewers.

Copy link
Member

@bf4 bf4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change to recommend putting in an initializer. I'd also advocate requiring the lib in that spot, rather than relying on something upstream doing it.

You can also disable the logger, just put this in `config/application.rb`:

```ruby
ActiveSupport::Notifications.unsubscribe(ActiveModelSerializers::Logging::RENDER_EVENT)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a better practice to put this in an initializer in a Rails app.

config/initializers/active_model_serializers.rb is the usual location.

require 'active_model_serializers'
ActiveSupport::Notifications.unsubscribe(ActiveModelSerializers::Logging::RENDER_EVENT)

and perhaps reference the relevant railtie https://github.com/rails-api/active_model_serializers/blob/0-10-stable/lib/active_model_serializers/railtie.rb#L23-L27 ?

Copy link
Contributor Author

@msathieu msathieu Jan 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why requiring it, that's done by Rails.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@msathieu not exactly. It's actually the call to Bundle.require at the top of most config/application.rb and then only if the gem doesn't have require: false.

Also, relying on autoloading of your project's classes is pretty much required for code reloading to work. But that doesn't really apply to gems. It's a good idea to require a gem before you use it. But this opinion is controversial enough that I won't tell you to include it :)

@bf4
Copy link
Member

bf4 commented Jan 17, 2017

@msathieu Thanks so much for this and the quick turnaround!

@msathieu
Copy link
Contributor Author

@bf4 Updated it to use an initializer

@msathieu
Copy link
Contributor Author

@bf4 I have updated it to require active_model_serializers in the initializer

@bf4
Copy link
Member

bf4 commented Jan 22, 2017

@msathieu would you mind adding a changelog entry for yourself under 'misc'?

@msathieu
Copy link
Contributor Author

msathieu commented Jan 23, 2017

@bf4 I've made an entry.

@bf4 bf4 merged commit 2d1c680 into rails-api:master Jan 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants