forked from DMPRoadmap/roadmap
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
Rails.application.configure do | ||
config.lograge.enabled = true | ||
|
||
# Use the LogStash format | ||
config.lograge.formatter = Lograge::Formatters::Logstash.new | ||
|
||
# Include controller info in the available log payload | ||
config.lograge.custom_payload do |controller| | ||
{ | ||
host: controller.request.host, | ||
user_id: controller.current_user.try(:id) | ||
params: controller.params | ||
} | ||
end | ||
|
||
# Include the custom info from the event and payload | ||
config.lograge.custom_options = lambda do |event| | ||
param_exceptions = %w(controller action format id) | ||
|
||
{ | ||
# Timestamp | ||
time: event.time, | ||
# Controller params | ||
params: event.payload[:params].except(*param_exceptions), | ||
# The current user | ||
user: event.payload[:user_id], | ||
# Caller | ||
host: event.payload[:host] | ||
} | ||
end | ||
|
||
# Continue creating the basic Rails logs | ||
config.lograge.keep_original_rails_log = true | ||
|
||
# Define the location of the Lograge format | ||
config.lograge.logger = ActiveSupport::Logger.new "#{Rails.root}/log/lograge_#{Rails.env}.log" | ||
end |