Active_model_serializers: Add an option to remove log messages

Created on 14 Jan 2017  路  6Comments  路  Source: rails-api/active_model_serializers

I would like an option to turn this
[active_model_serializers] Rendered ActiveModel::Serializer::CollectionSerializer with ActiveModelSerializers::Adapter::JsonApi (136.7ms)
log message of.

Documentation 0.10.x

Most helpful comment

@bf4 ActiveModelSerializers.logger = Logger.new(nil) doesn't works,
ActiveModelSerializers.logger = Logger.new(IO::NUL) raises an error,
but ActiveSupport::Notifications.unsubscribe(ActiveModelSerializers::Logging::RENDER_EVENT) works perfectly

All 6 comments

@MSathieu Of course. We should reference that in docs/general/logging.md along with the log subscriber and active support notifications api.

It's unclear to me if you want to

  • set ActiveModelSerializers.logger = Logger.new(IO::NUL) or ActiveModelSerializers.logger = Logger.new(nil)
  • just unsubscribe ActiveSupport::Notifications.unsubscribe(ActiveModelSerializers::Logging::RENDER_EVENT)

    • and maybe ActiveSupport::LogSubscriber.log_subscribers.delete_if {|subscriber| subscriber.instance_of?(ActiveModelSerializers::Logging::LogSubscriber) }

though I haven't tried these myself.

I want to set ActiveModelSerializers.logger = Logger.new(nil)

@MSathieu did that resolve your issue?

@bf4 ActiveModelSerializers.logger = Logger.new(nil) doesn't works,
ActiveModelSerializers.logger = Logger.new(IO::NUL) raises an error,
but ActiveSupport::Notifications.unsubscribe(ActiveModelSerializers::Logging::RENDER_EVENT) works perfectly

@MSathieu Would you like to make a PR to improve the docs, especially based on how you went about looking for the info?

I will do that.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

attenzione picture attenzione  路  4Comments

djsegal picture djsegal  路  5Comments

Andriykoo picture Andriykoo  路  5Comments

NullVoxPopuli picture NullVoxPopuli  路  4Comments

seoyoochan picture seoyoochan  路  4Comments