-
-
Notifications
You must be signed in to change notification settings - Fork 293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add current_user support #23
Comments
I've started working on a branch that brings support for tagged logging to lograge, which would be much more fitting in this case, as it'd utilize something Rails already has support for. |
I've been looking for a solution to this issue because that would be tremendously useful. You can use a Rails' hook method in Instrumentation called def append_info_to_payload(payload)
super
payload[:uid] = current_user.id if logged_in?
end Then you can use: config.lograge.custom_options = lambda do |event|
{ :uid => event.payload[:uid] }
end |
We are using |
@nathany I'm going thru this issue myself. The main thing I'm noticing is that lograge's payload would only apply to things it is subscribed to (namely However if you have any generic logging happening elsewhere the application you want the tags attached to you will still need to use the tags (i.e a log even happening within model code where you want the current user_id included in the log method w/o knowing at the model level what it is. But if you just want it for the general "request completed" lograge will do the trick |
After switching to |
+1000 for this feature builtin in lograge. |
just want to say freegenie's option from '12 still works great in Rails 4.2 / Ruby 2.2 for Devise there are a few ways to check for logged in - I went with def append_info_to_payload(payload)
super
payload[:uid] = current_user.id unless current_user.nil?
end |
@tongboy instead of current_user.nil? - you should use user_signed_in? |
I'd love it if lograge would auto-support
current_user
logging, something like:We find it vital for debugging and 'watching' how a user got into a particular state.
The text was updated successfully, but these errors were encountered: