Skip to content

Commit

Permalink
GRN2-xx: Switched to Lograge for logging and increased log level to i…
Browse files Browse the repository at this point in the history
…nfo (bigbluebutton#694)

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

* Travis fixes

* Travis fixes 2
  • Loading branch information
farhatahmad authored and jfederico committed Jul 25, 2019
1 parent a080d3d commit c472f75
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 8 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -357,6 +364,7 @@ DEPENDENCIES
jbuilder (~> 2.5)
jquery-rails (~> 4.3.3)
listen (~> 3.0.5)
lograge
mini_racer
net-ldap
omniauth
Expand Down
6 changes: 6 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
22 changes: 16 additions & 6 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,20 @@
# 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)
Expand All @@ -108,8 +116,10 @@
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.
Expand Down

0 comments on commit c472f75

Please sign in to comment.