You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

65 lines
2.4 KiB

return if Rails.application.tailwind_watcher?
Rails.application.config.x.action_controller.main_session_tag = 'toto1'
Rails.application.config.x.action_controller.main_session_tag_fixed_length = 8
def build_instrumentation_config
{
action_controller: true,
action_view: Live::Constants::ACTION_VIEW,
active_record: Live::Constants::ACTIVE_RECORD
}.map do |key, value|
key if value
end.compact
end
Rails.configuration.after_initialize do
RailsSemanticLogger::Rack::Logger.logger.level = :info # useful for remaining log like "[Rack::Log] Started..."
SemanticLogger.default_level = :debug
Rails.logger.name = 'rails'
if Rails.env.production?
appender = :syslog
formatter = Rails.application.config.x.semantic.formatter.constantize.new
SemanticLogger.add_appender(appender:, formatter:)
Semantic::Instrumentalizer.activate(*build_instrumentation_config)
if Rails.application.rake? || Rails.application.console?
io_formatter = Rails.application.config.x.semantic.formatter.constantize.new(time_format: '%H:%M:%S')
SemanticLogger.add_appender(io: $stdout, formatter: io_formatter)
end
else
SemanticLogger.clear_appenders!
SemanticLogger.add_appender(
io: $stdout,
formatter: Rails.application.config.x.semantic.formatter.constantize.new(
time_format: Rails.application.procfile_server? ? nil : '%H:%M:%S'
)
)
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?
Semantic::Instrumentalizer.activate(*build_instrumentation_config)
end
end
Rails.autoloaders.main.on_load('ApplicationController') do
SemanticLogger.clear_appenders!
SemanticLogger.add_appender(
io: $stdout,
formatter: Rails.application.config.x.semantic.formatter.constantize.new(
time_format: Rails.application.procfile_server? ? nil : '%H:%M:%S'
)
)
Rails.logger.info ' ', dimensions: Semantic::FancyDimensions.new(rails: '╔═╗', before: 1)
Rails.logger.fatal 'Zeitwerk RELOAD!', dimensions: Semantic::FancyDimensions.new(rails: '╠█╣')
Rails.logger.info ' ', dimensions: Semantic::FancyDimensions.new(rails: '╚═╝')
Semantic::Instrumentalizer.activate(*build_instrumentation_config)
end
end
end