Skip to content

Commit 951c7c8

Browse files
authored
Merge pull request #2342 from till/master
fix(logging): implement semantic logger
2 parents 54bb699 + 9b9ab8c commit 951c7c8

File tree

4 files changed

+21
-8
lines changed

4 files changed

+21
-8
lines changed

Gemfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ gem 'rails', '~> 7.1.5.1' # LOCKED: It is Rails.
55
# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
66
gem 'sprockets-rails'
77

8+
gem "amazing_print" # colourful output (suggested by rails_semantic_logger)
9+
gem "rails_semantic_logger" # condense log lines: https://github.com/codebar/planner/issues/2339
10+
811
gem 'acts-as-taggable-on'
912
gem 'benchmark' # LOCKED: Added because of activesupport 7.0
1013
gem 'bigdecimal' # LOCKED: Added because of activesupport 7.0
@@ -114,7 +117,6 @@ end
114117

115118
group :production do
116119
gem 'foreman'
117-
gem 'rails_12factor'
118120
end
119121

120122
gem 'rollbar'

Gemfile.lock

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ GEM
8383
zeitwerk (>= 2.4, < 3.0)
8484
addressable (2.8.7)
8585
public_suffix (>= 2.0.2, < 7.0)
86+
amazing_print (1.8.1)
8687
ast (2.4.3)
8788
aws-eventstream (1.4.0)
8889
aws-partitions (1.1137.0)
@@ -397,11 +398,10 @@ GEM
397398
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
398399
rails4-autocomplete (1.1.1)
399400
rails (>= 3.0)
400-
rails_12factor (0.0.3)
401-
rails_serve_static_assets
402-
rails_stdout_logging
403-
rails_serve_static_assets (0.0.5)
404-
rails_stdout_logging (0.0.5)
401+
rails_semantic_logger (4.18.0)
402+
rack
403+
railties (>= 5.1)
404+
semantic_logger (~> 4.16)
405405
railties (7.1.5.1)
406406
actionpack (= 7.1.5.1)
407407
activesupport (= 7.1.5.1)
@@ -496,6 +496,8 @@ GEM
496496
rexml (~> 3.2, >= 3.2.5)
497497
rubyzip (>= 1.2.2, < 4.0)
498498
websocket (~> 1.0)
499+
semantic_logger (4.17.0)
500+
concurrent-ruby (~> 1.0)
499501
shoulda-matchers (6.5.0)
500502
activesupport (>= 5.2.0)
501503
simple_form (5.3.1)
@@ -565,6 +567,7 @@ PLATFORMS
565567

566568
DEPENDENCIES
567569
acts-as-taggable-on
570+
amazing_print
568571
benchmark
569572
better_errors
570573
bigdecimal
@@ -621,7 +624,7 @@ DEPENDENCIES
621624
rails (~> 7.1.5.1)
622625
rails-html-sanitizer (~> 1.6.2)
623626
rails4-autocomplete
624-
rails_12factor
627+
rails_semantic_logger
625628
reline
626629
rolify
627630
rollbar

config/application.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,11 @@ class Application < Rails::Application
4646
config.active_record.yaml_column_permitted_classes = [Symbol, Date, Time, ActiveSupport::TimeWithZone, ActiveSupport::TimeZone, ActiveSupport::HashWithIndifferentAccess]
4747

4848
config.active_record.belongs_to_required_by_default = true
49+
50+
if ENV["RAILS_LOG_TO_STDOUT"].present?
51+
$stdout.sync = true
52+
config.rails_semantic_logger.add_file_appender = false
53+
config.semantic_logger.add_appender(io: $stdout, formatter: config.rails_semantic_logger.format)
54+
end
4955
end
50-
end
56+
end

config/puma.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,6 @@
4949
ActiveSupport.on_load(:active_record) do
5050
ActiveRecord::Base.establish_connection
5151
end
52+
53+
SemanticLogger.reopen
5254
end

0 commit comments

Comments
 (0)