am-kantox / kantox-herro

Handle errors in RoR with pleasure.
MIT License
0 stars 0 forks source link

Add remote address, session_id and request_id to the log #3

Open epaune-k opened 9 years ago

epaune-k commented 9 years ago

Session id is stored in env variable _APPNAME_session_id request_id in action_dispatch.request_id, added by middleware ActionDispatch::RequestId This middleware is after Rack::Cache in the middleware stack, so we need to remove and add it before HackMiddlewareSettings

epaune-k commented 9 years ago

But this only adds this variables when there is an error, but not in the general log, isn't it? If you don't want to add them now in the gem, we could add them in application using rails tagged logger:

config.log_tags = [
  :uuid, #request_id
  :remote_ip,
  lambda { |req|
     if req.cookie_jar && session_id = req.cookie_jar.signed['_kantox_session_id']
       session_id
     else
       'no_session'
     end
  }
]
am-kantox commented 9 years ago

Good point. Reopened.