Created
May 17, 2018 22:23
-
-
Save srt32/c61c43fbd5b4ad45227b945ca51b1926 to your computer and use it in GitHub Desktop.
logging current user.id in Rails logs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config.log_tags = [ | |
:request_id, | |
:subdomain, | |
->(req) { | |
session_key = (Rails.application.config.session_options || {})[:key] | |
session_data = req.cookie_jar.encrypted[session_key] || {} | |
user_id = session_data["user_id"] || "guest" | |
"user: #{user_id.to_s}" | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment