Hey, thanks for this great gem. I'm trying to figure out the recommended approach for adding custom fields at the controller level. For instance, we want to log some custom fields in our Admin controllers. The docs suggest you should do this in an initializer like so:
config/initializers/logstasher.rb
LogStasher.add_custom_fields do |fields|
fields[:admin_id] = current_admin.id if request.path =~ /^\/admin/
end
Instead of doing the path matching, I was hoping to add custom fields directly in our AdminController. I landed on this approach (almost identical to lograge's approach):
app/controllers/admin_controller.rb
def append_info_to_payload(payload)
super
LogStasher.store[:admin_user_id] = current_admin.id
end
This works for well for us, but since I couldn't find any documentation around this use-case I wanted to see if you recommend a different approach. Thanks in advance!
Hey, thanks for this great gem. I'm trying to figure out the recommended approach for adding custom fields at the controller level. For instance, we want to log some custom fields in our Admin controllers. The docs suggest you should do this in an initializer like so:
config/initializers/logstasher.rb
Instead of doing the path matching, I was hoping to add custom fields directly in our
AdminController
. I landed on this approach (almost identical to lograge's approach):app/controllers/admin_controller.rb
This works for well for us, but since I couldn't find any documentation around this use-case I wanted to see if you recommend a different approach. Thanks in advance!