oink
oink copied to clipboard
Allow logging of specified environment variables.
This PR allows users to log extra environment information to the oink.log, if environment keys are specified.
If an optional env_vars
array is passed to the middleware, the logs will have an additional Environment:
line with specified environment keys and values:
Rails.application.middleware.use( Oink::Middleware, env_vars: ['action_dispatch.request_id'] )
Jan 29 18:28:39 vocalhost rails[74025]: Oink Action: home#show
Jan 29 18:28:39 vocalhost rails[74025]: Environment: {"action_dispatch.request_id": "4cc822f8-0d85-4d80-bcae-d94a4567e06c"}
Jan 29 18:28:39 vocalhost rails[74025]: Memory usage: 4825792 | PID: 74025
Jan 29 18:28:39 vocalhost rails[74025]: Instantiation Breakdown: Total: 2 | Page: 1 | User: 1
Jan 29 18:28:39 vocalhost rails[74025]: Oink Log Entry Complete
This is especially useful for logging the request ID, since logs may be distributed among multiple app servers, and timestamps don't always line up exactly.