Browse Source

formatter configurable

main
pvincent 2 months ago
parent
commit
9d22c2699a
  1. 6
      config/environments/development.rb
  2. 11
      config/initializers/instrumentalizing.rb
  3. 6
      config/puma.rb

6
config/environments/development.rb

@ -77,8 +77,6 @@ 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'
Rails.configuration.after_initialize do
# SemanticLogger.add_appender(io: $stdout, formatter: Semantic::BasicFormatter.new)
SemanticLogger.add_appender(io: $stdout, formatter: Semantic::FancyFormatter.new)
end
# config.x.semantic.formatter = 'Semantic::BasicFormatter'
config.x.semantic.formatter = 'Semantic::FancyFormatter'
end

11
config/initializers/instrumentalizing.rb

@ -1,9 +1,12 @@
return if Rails.application.tailwind_watcher?
return unless Rails.application.server?
if Rails.env.development?
RailsSemanticLogger::Rack::Logger.logger.level = :info # useful for remaining log like "[Rack::Log] Started..."
SemanticLogger.clear_appenders!
return unless Rails.application.server?
Rails.logger.name = 'rails'
end
def build_instrumentation_config
{
@ -16,8 +19,6 @@ def build_instrumentation_config
end
Rails.configuration.after_initialize do
Rails.logger.name = 'rails'
ActiveSupport::Notifications.subscribe('rolling.live_constant') do |event|
constants = event.payload[:changes].map { |change| change[:constant] }
if constants.intersection(%w[ACTIVE_RECORD ACTION_VIEW]).any?
@ -28,7 +29,7 @@ end
Rails.autoloaders.main.on_load('ApplicationController') do
SemanticLogger.clear_appenders!
SemanticLogger.add_appender(io: $stdout, formatter: Semantic::FancyFormatter.new)
SemanticLogger.add_appender(io: $stdout, formatter: Rails.application.config.x.semantic.formatter.constantize.new)
Rails.logger.info ' ', dimensions: Semantic::FancyDimensions.new(rails: '╔═╗', before: 1)
Rails.logger.fatal 'Zeitwerk RELOAD!', dimensions: Semantic::FancyDimensions.new(rails: '╠█╣')

6
config/puma.rb

@ -34,6 +34,6 @@ pidfile ENV.fetch('PIDFILE') { 'tmp/pids/server.pid' }
# Allow puma to be restarted by `bin/rails restart` command.
plugin :tmp_restart
on_booted do
puts '********************* PUMA: booted **********************'
end
# on_booted do
# puts '********************* PUMA: booted **********************'
# end
Loading…
Cancel
Save