Module: MrLogaLoga::Extensions::RailsExtension
- Defined in:
- lib/mr_loga_loga/extensions/rails.rb
Overview
Description
This patches Rails to allow it to work with loggers that accept keyword arguments.
Per default, Rails patches any logger during server startup to be able to broadcast any log messages to the console. This patch assumes that loggers only take args and blocks, so we have to change that.
During server startup Rails will always use the ActiveSupport::Logger to send data to the console. This was modified o changed to always use the user-configured logger.
Patches
-
ActiveSupport::Logger#self.broadcast
-
Rails::Server#log_to_stdout
Defined Under Namespace
Modules: LoggerPatch, ServerPatch
Class Method Summary collapse
Class Method Details
.apply ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/mr_loga_loga/extensions/rails.rb', line 22 def apply return unless defined?(Rails) logger_defined = defined?(ActiveSupport::Logger) unless logger_defined && broadcast_method puts "WARNING: Failed to patch ActiveSupport::Logger. It looks like MrLogaLoga's patch in #{__FILE__} no "\ "longer applies. Please contact MrLogaLoga's maintainers." return end server_defined = defined?(Rails::Server) unless server_defined && Rails::Server.private_method_defined?(:log_to_stdout) puts "WARNING: Failed to patch Rails::Server. It looks like MrLogaLoga's patch in #{__FILE__} no "\ "longer applies. Please contact MrLogaLoga's maintainers." return end ActiveSupport::Logger.include(LoggerPatch) Rails::Server.prepend(ServerPatch) end |