|
|
@ -77,10 +77,43 @@ Rails.application.configure do # rubocop:disable Metrics/BlockLength |
|
|
|
routes.default_url_options[:port] = ARGV[1] # ie: Procfile.dev --port PORT |
|
|
|
routes.default_url_options[:host] = '127.0.0.1' |
|
|
|
|
|
|
|
config.after_initialize do |
|
|
|
formatter = Semantic::AnsiFormatter.new |
|
|
|
config.semantic_logger.add_appender(io: $stdout, |
|
|
|
formatter:, |
|
|
|
filter: ->(log) { !formatter.reject(log) }) |
|
|
|
if Rails.application.console? |
|
|
|
config.after_initialize do |
|
|
|
formatter = Semantic::BasicFormatter.new |
|
|
|
SemanticLogger.add_appender(io: $stdout, formatter:) |
|
|
|
|
|
|
|
# SemanticLogger.add_appender(io: $stdout, |
|
|
|
# formatter:, |
|
|
|
# filter: ->(log) { !formatter.reject(log) }) |
|
|
|
end |
|
|
|
elsif Rails.application.server? |
|
|
|
|
|
|
|
config.after_initialize do |
|
|
|
source_location = Semantic::AnsiFormatter.instance_method(:initialize).source_location[0] |
|
|
|
previous_mtime = File.stat(source_location).mtime |
|
|
|
formatter = Semantic::AnsiFormatter.new |
|
|
|
# SemanticLogger.clear_appenders! |
|
|
|
SemanticLogger.add_appender(io: $stdout, |
|
|
|
formatter:, |
|
|
|
filter: ->(log) { !formatter.reject(log) }) |
|
|
|
|
|
|
|
[Semantic::AnsiFormatter, ApplicationController].each do |class_name| |
|
|
|
Rails.autoloaders.main.on_load(class_name.to_s) do |klass, abspath| |
|
|
|
if klass == Semantic::AnsiFormatter |
|
|
|
mtime = File.stat(source_location).mtime |
|
|
|
if previous_mtime != mtime |
|
|
|
previous_mtime = mtime |
|
|
|
SemanticLogger.clear_appenders! |
|
|
|
formatter = Semantic::AnsiFormatter.new |
|
|
|
SemanticLogger.add_appender(io: $stdout, |
|
|
|
formatter:, |
|
|
|
filter: lambda { |log| |
|
|
|
!formatter.reject(log) |
|
|
|
}) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |