forked from External/greenlight
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:
parent
a080d3dd62
commit
c472f751a1
3
Gemfile
3
Gemfile
|
@ -80,6 +80,9 @@ gem 'cancancan', '~> 2.0'
|
||||||
group :production do
|
group :production do
|
||||||
# Use a postgres database in production.
|
# Use a postgres database in production.
|
||||||
gem 'pg', '~> 0.18'
|
gem 'pg', '~> 0.18'
|
||||||
|
|
||||||
|
# For a better logging library in production
|
||||||
|
gem "lograge"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Ruby linting.
|
# Ruby linting.
|
||||||
|
|
|
@ -155,6 +155,11 @@ GEM
|
||||||
listen (3.0.8)
|
listen (3.0.8)
|
||||||
rb-fsevent (~> 0.9, >= 0.9.4)
|
rb-fsevent (~> 0.9, >= 0.9.4)
|
||||||
rb-inotify (~> 0.9, >= 0.9.7)
|
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)
|
loofah (2.2.3)
|
||||||
crass (~> 1.0.2)
|
crass (~> 1.0.2)
|
||||||
nokogiri (>= 1.5.9)
|
nokogiri (>= 1.5.9)
|
||||||
|
@ -250,6 +255,8 @@ GEM
|
||||||
redcarpet (3.4.0)
|
redcarpet (3.4.0)
|
||||||
remote_syslog_logger (1.0.4)
|
remote_syslog_logger (1.0.4)
|
||||||
syslog_protocol
|
syslog_protocol
|
||||||
|
request_store (1.4.1)
|
||||||
|
rack (>= 1.4)
|
||||||
rolify (5.2.0)
|
rolify (5.2.0)
|
||||||
rspec-core (3.8.2)
|
rspec-core (3.8.2)
|
||||||
rspec-support (~> 3.8.0)
|
rspec-support (~> 3.8.0)
|
||||||
|
@ -357,6 +364,7 @@ DEPENDENCIES
|
||||||
jbuilder (~> 2.5)
|
jbuilder (~> 2.5)
|
||||||
jquery-rails (~> 4.3.3)
|
jquery-rails (~> 4.3.3)
|
||||||
listen (~> 3.0.5)
|
listen (~> 3.0.5)
|
||||||
|
lograge
|
||||||
mini_racer
|
mini_racer
|
||||||
net-ldap
|
net-ldap
|
||||||
omniauth
|
omniauth
|
||||||
|
|
|
@ -44,6 +44,12 @@ class ApplicationController < ActionController::Base
|
||||||
MEETING_NAME_LIMIT = 90
|
MEETING_NAME_LIMIT = 90
|
||||||
USER_NAME_LIMIT = 32
|
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.
|
# Show an information page when migration fails and there is a version error.
|
||||||
def migration_error?
|
def migration_error?
|
||||||
render :migration_error unless ENV["DB_MIGRATE_FAILED"].blank?
|
render :migration_error unless ENV["DB_MIGRATE_FAILED"].blank?
|
||||||
|
|
|
@ -94,12 +94,20 @@ Rails.application.configure do
|
||||||
# Send deprecation notices to registered listeners.
|
# Send deprecation notices to registered listeners.
|
||||||
config.active_support.deprecation = :notify
|
config.active_support.deprecation = :notify
|
||||||
|
|
||||||
# Use default logging formatter so that PID and timestamp are not suppressed.
|
# Use Lograge for logging
|
||||||
config.log_formatter = ::Logger::Formatter.new
|
config.lograge.enabled = true
|
||||||
|
|
||||||
# Use a different logger for distributed setups.
|
config.lograge.ignore_actions = ["HealthCheck::HealthCheckController#index"]
|
||||||
# require 'syslog/logger'
|
|
||||||
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
|
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"
|
if ENV["RAILS_LOG_TO_STDOUT"] == "true"
|
||||||
logger = ActiveSupport::Logger.new(STDOUT)
|
logger = ActiveSupport::Logger.new(STDOUT)
|
||||||
|
@ -108,8 +116,10 @@ Rails.application.configure do
|
||||||
elsif ENV["RAILS_LOG_REMOTE_NAME"] && ENV["RAILS_LOG_REMOTE_PORT"]
|
elsif ENV["RAILS_LOG_REMOTE_NAME"] && ENV["RAILS_LOG_REMOTE_PORT"]
|
||||||
require 'remote_syslog_logger'
|
require 'remote_syslog_logger'
|
||||||
logger_program = ENV["RAILS_LOG_REMOTE_TAG"] || "greenlight-#{ENV['RAILS_ENV']}"
|
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)
|
ENV["RAILS_LOG_REMOTE_PORT"], program: logger_program)
|
||||||
|
logger.formatter = config.log_formatter
|
||||||
|
config.logger = ActiveSupport::TaggedLogging.new(logger)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Do not dump schema after migrations.
|
# Do not dump schema after migrations.
|
||||||
|
|
Loading…
Reference in New Issue