GRN2-xx: Switched to Lograge for logging and increased log level to info (#694)

* Switched to Lograge for logging and increased log level to info

* Travis fixes

* Travis fixes 2
This commit is contained in:
farhatahmad 2019-07-25 15:07:56 -04:00 committed by Jesus Federico
parent a080d3dd62
commit c472f751a1
4 changed files with 33 additions and 6 deletions

View File

@ -80,6 +80,9 @@ gem 'cancancan', '~> 2.0'
group :production do
# Use a postgres database in production.
gem 'pg', '~> 0.18'
# For a better logging library in production
gem "lograge"
end
# Ruby linting.

View File

@ -155,6 +155,11 @@ GEM
listen (3.0.8)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
lograge (0.11.2)
actionpack (>= 4)
activesupport (>= 4)
railties (>= 4)
request_store (~> 1.0)
loofah (2.2.3)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
@ -250,6 +255,8 @@ GEM
redcarpet (3.4.0)
remote_syslog_logger (1.0.4)
syslog_protocol
request_store (1.4.1)
rack (>= 1.4)
rolify (5.2.0)
rspec-core (3.8.2)
rspec-support (~> 3.8.0)
@ -357,6 +364,7 @@ DEPENDENCIES
jbuilder (~> 2.5)
jquery-rails (~> 4.3.3)
listen (~> 3.0.5)
lograge
mini_racer
net-ldap
omniauth

View File

@ -44,6 +44,12 @@ class ApplicationController < ActionController::Base
MEETING_NAME_LIMIT = 90
USER_NAME_LIMIT = 32
# Include user domain in lograge logs
def append_info_to_payload(payload)
super
payload[:host] = @user_domain
end
# Show an information page when migration fails and there is a version error.
def migration_error?
render :migration_error unless ENV["DB_MIGRATE_FAILED"].blank?

View File

@ -94,12 +94,20 @@ Rails.application.configure do
# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
# Use Lograge for logging
config.lograge.enabled = true
# Use a different logger for distributed setups.
# require 'syslog/logger'
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
config.lograge.ignore_actions = ["HealthCheck::HealthCheckController#index"]
config.lograge.custom_options = lambda do |event|
# capture some specific timing values you are interested in
{ host: event.payload[:host] }
end
config.log_formatter = proc do |severity, _time, _progname, msg|
"#{severity}: #{msg} \n"
end
config.log_level = :info
if ENV["RAILS_LOG_TO_STDOUT"] == "true"
logger = ActiveSupport::Logger.new(STDOUT)
@ -108,8 +116,10 @@ Rails.application.configure do
elsif ENV["RAILS_LOG_REMOTE_NAME"] && ENV["RAILS_LOG_REMOTE_PORT"]
require 'remote_syslog_logger'
logger_program = ENV["RAILS_LOG_REMOTE_TAG"] || "greenlight-#{ENV['RAILS_ENV']}"
config.logger = RemoteSyslogLogger.new(ENV["RAILS_LOG_REMOTE_NAME"],
logger = RemoteSyslogLogger.new(ENV["RAILS_LOG_REMOTE_NAME"],
ENV["RAILS_LOG_REMOTE_PORT"], program: logger_program)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
# Do not dump schema after migrations.