Skip to content

Commit

Permalink
SRCH-1888 prevent Elasticsearch from logging when 'log' is false (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
MothOnMars authored Feb 4, 2021
1 parent 12103c2 commit 3ae1788
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions config/initializers/elasticsearch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
reload_connections: true
)

logger = ActiveSupport::Logger.new("log/#{Rails.env}.log")
logger.level = Rails.configuration.elasticsearch['log_level']
logger.formatter = proc do |severity, time, _progname, msg|
"\e[2m[ES][#{time.utc.iso8601(6)}][#{severity}] #{msg}\n\e[0m"
if Rails.configuration.elasticsearch['log']
logger = ActiveSupport::Logger.new("log/#{Rails.env}.log")
logger.level = Rails.configuration.elasticsearch['log_level']
logger.formatter = proc do |severity, time, _progname, msg|
"\e[2m[ES][#{time.utc.iso8601(6)}][#{severity}] #{msg}\n\e[0m"
end
Elasticsearch::Persistence.client.transport.logger = logger
end
Elasticsearch::Persistence.client.transport.logger = logger

if Rails.env.development?
puts 'Ensuring Elasticsearch development indexes and aliases are available....'
Expand Down

0 comments on commit 3ae1788

Please sign in to comment.