Compare commits

...

8 commits

Author SHA1 Message Date
Sojan Jose
8de0293ab5
Merge branch 'develop' into feat/add_lograge 2022-11-02 18:00:00 -07:00
Sojan Jose
c17cec14d8
Merge branch 'develop' into feat/add_lograge 2022-10-10 22:26:15 -07:00
Vishnu Narayanan
a4e1730297
Merge branch 'develop' into feat/add_lograge 2022-09-15 16:59:45 +05:30
Vishnu Narayanan
c0857f329e
chore: add remote_ip to lograge 2022-09-15 16:47:50 +05:30
Vishnu Narayanan
3a04a8af36
feat: configure lograge 2022-09-14 21:18:26 +05:30
Vishnu Narayanan
1ba2199712
feat: configure lograge 2022-09-14 21:17:00 +05:30
Vishnu Narayanan
904cfbc316
chore: remove rails default log 2022-09-12 19:15:56 +05:30
Vishnu Narayanan
5e54992987
feat: add lograge to improve logging 2022-09-12 16:14:56 +05:30
9 changed files with 51 additions and 1 deletions

View file

@ -186,3 +186,5 @@ group :development, :test do
gem 'spring'
gem 'spring-watcher-listen'
end
gem 'lograge', '~> 0.12.0'

View file

@ -398,6 +398,11 @@ GEM
llhttp-ffi (0.4.0)
ffi-compiler (~> 1.0)
rake (~> 13.0)
lograge (0.12.0)
actionpack (>= 4)
activesupport (>= 4)
railties (>= 4)
request_store (~> 1.0)
loofah (2.18.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
@ -509,6 +514,8 @@ GEM
declarative (< 0.1.0)
trailblazer-option (>= 0.1.1, < 0.2.0)
uber (< 0.2.0)
request_store (1.5.1)
rack (>= 1.4)
responders (3.0.1)
actionpack (>= 5.0)
railties (>= 5.0)
@ -753,6 +760,7 @@ DEPENDENCIES
line-bot-api
liquid
listen
lograge (~> 0.12.0)
maxminddb
mock_redis
newrelic_rpm

View file

@ -24,4 +24,16 @@ class ApplicationController < ActionController::Base
account_user: Current.account_user
}
end
def append_info_to_payload(payload)
super
payload[:level] = case payload[:status]
when 200
'INFO'
when 302
'WARN'
else
'ERROR'
end
end
end

View file

@ -76,5 +76,5 @@ Rails.application.configure do
Bullet.bullet_logger = true
Bullet.rails_logger = true
end
end

View file

@ -103,4 +103,5 @@ Rails.application.configure do
config.action_mailbox.ingress = ENV.fetch('RAILS_INBOUND_EMAIL_SERVICE', 'relay').to_sym
Rails.application.routes.default_url_options = { host: ENV['FRONTEND_URL'] }
end

View file

@ -75,4 +75,5 @@ Rails.application.configure do
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
end

View file

@ -51,4 +51,5 @@ Rails.application.configure do
# Raises error for missing translations.
# config.action_view.raise_on_missing_translations = true
config.log_level = ENV.fetch('LOG_LEVEL', 'debug').to_sym
end

View file

@ -0,0 +1,24 @@
Rails.application.configure do
config.lograge.enabled = true
config.lograge.keep_original_rails_log = true
config.lograge.formatter = Lograge::Formatters::Json.new
config.colorize_logging = false
config.lograge.custom_payload do |controller|
{
host: controller.request.host,
remote_ip: controller.request.remote_ip,
user_id: controller.current_user.try(:id)
}
end
config.lograge.custom_options = lambda do |event|
{
level: event.payload[:level]
}
end
config.lograge.ignore_custom = lambda do |event|
# ignore update_presence events in log
return true if event.payload[:channel_class] == 'RoomChannel'
end
end

View file

@ -7,6 +7,7 @@ Sidekiq.configure_client do |config|
end
Sidekiq.configure_server do |config|
config.logger.formatter = Sidekiq::Logger::Formatters::JSON.new
config.redis = Redis::Config.app
config.logger.level = Logger.const_get(ENV.fetch('LOG_LEVEL', 'info').upcase.to_s)
end