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.
 
 
 
 
 

53 lines
1.9 KiB

return unless Rails.application.server?
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..."
Rails.logger.name = 'rails'
if Rails.env.production?
formatter = Rails.application.config.x.semantic.formatter.constantize.new
SemanticLogger.add_appender(appender: :syslog, formatter:)
Semantic::Instrumentalizer.activate(*build_instrumentation_config)
else
SemanticLogger.clear_appenders!
SemanticLogger.add_appender(
io: $stdout,
formatter: Rails.application.config.x.semantic.formatter.constantize.new
)
Rails.autoloaders.main.on_load('ApplicationController') do
SemanticLogger.clear_appenders!
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: '╠█╣')
Rails.logger.info ' ', dimensions: Semantic::FancyDimensions.new(rails: '╚═╝')
Semantic::Instrumentalizer.activate(*build_instrumentation_config)
end
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
end
end