Skip to content

Commit

Permalink
🪵 Use rails_semantic_logger for logging
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerwillingham committed Sep 6, 2024
1 parent ccff501 commit a862530
Show file tree
Hide file tree
Showing 6 changed files with 4,963 additions and 3 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ gem 'importmap-rails'
gem 'packwerk', '~> 3.1'
gem 'pg', '~> 1.1'
gem 'puma', '>= 5.0'
gem 'rails_semantic_logger'
gem 'sorbet-static-and-runtime'
gem 'sprockets-rails'
gem 'stimulus-rails'
Expand Down
7 changes: 7 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ GEM
rails-html-sanitizer (1.6.0)
loofah (~> 2.21)
nokogiri (~> 1.14)
rails_semantic_logger (4.17.0)
rack
railties (>= 5.1)
semantic_logger (~> 4.16)
railties (7.2.1)
actionpack (= 7.2.1)
activesupport (= 7.2.1)
Expand Down Expand Up @@ -286,6 +290,8 @@ GEM
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
semantic_logger (4.16.1)
concurrent-ruby (~> 1.0)
smart_properties (1.17.0)
sorbet (0.5.11554)
sorbet-static (= 0.5.11554)
Expand Down Expand Up @@ -365,6 +371,7 @@ DEPENDENCIES
public_site!
puma (>= 5.0)
rails
rails_semantic_logger
rspec-rails
rubocop
rubocop-rails
Expand Down
2 changes: 2 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,7 @@ class Application < Rails::Application
#
# config.time_zone = "Central Time (US & Canada)"
# config.eager_load_paths << Rails.root.join("extras")

config.semantic_logger.application = 'twilling.io'
end
end
9 changes: 6 additions & 3 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,12 @@
# config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } }

# Log to STDOUT by default
config.logger = ActiveSupport::Logger.new($stdout)
.tap { |logger| logger.formatter = ::Logger::Formatter.new }
.then { |logger| ActiveSupport::TaggedLogging.new(logger) }
# config.logger = ActiveSupport::Logger.new($stdout)
# .tap { |logger| logger.formatter = ::Logger::Formatter.new }
# .then { |logger| ActiveSupport::TaggedLogging.new(logger) }
$stdout.sync = true
config.rails_semantic_logger.add_file_appender = false
config.semantic_logger.add_appender io: $stdout, formatter: :json

# Prepend all log lines with the following tags.
config.log_tags = [:request_id]
Expand Down
Loading

0 comments on commit a862530

Please sign in to comment.