ActiveModelSerializers uses the ActiveSupport::Notification API, which allows for subscribing to events, such as for logging.
Name:
render.active_model_serializers
Payload (example):
{
serializer: PostSerializer,
adapter: ActiveModel::Serializer::Adapter::Attributes
}
Subscribing:
ActiveSupport::Notifications.subscribe 'render.active_model_serializers' do |name, started, finished, unique_id, data|
# whatever
end
ActiveSupport::Notifications.subscribe 'render.active_model_serializers' do |*args|
event = ActiveSupport::Notifications::Event.new(*args)
# event.payload
# whatever
end
ActiveModelSerializers includes an ActiveModelSerializers::LogSubscriber
that attaches to
render.active_model_serializers
.