diff --git a/lib/scout_apm/logging/loggers/logger.rb b/lib/scout_apm/logging/loggers/logger.rb index b2e5819..2aff3af 100644 --- a/lib/scout_apm/logging/loggers/logger.rb +++ b/lib/scout_apm/logging/loggers/logger.rb @@ -6,6 +6,21 @@ module Loggers # The actual instance of the logger. class FileLogger < ::Logger include ::ActiveSupport::LoggerSilence if const_defined?('::ActiveSupport::LoggerSilence') + + # Other loggers may be extended with additional methods that have not been applied to this file logger. + # Most likely, these methods will still utilize the exiting logging methods to write to the IO device, + # however, if this is not the case we may miss logs. With that being said, we shouldn't impact the original + # applications intended behavior and let the user know we don't support it and no-op. + def method_missing(name, *_args) + return unless defined?(::Rails) + + ::Rails.logger.warn("Method #{name} called on ScoutApm::Logging::Loggers::FileLogger, but it is not defined.") + end + + # More impactful for the broadcast logger. + def respond_to_missing?(name, *_args) + super + end end # The newly created logger which we can configure, and will log to a filepath. diff --git a/lib/scout_apm/logging/loggers/proxy.rb b/lib/scout_apm/logging/loggers/proxy.rb index 7d2c9e8..6601738 100644 --- a/lib/scout_apm/logging/loggers/proxy.rb +++ b/lib/scout_apm/logging/loggers/proxy.rb @@ -25,6 +25,22 @@ def remove_scout_loggers(logger) @loggers end + def is_a?(klass) + @loggers.first.is_a?(klass) + end + + def instance_of?(klass) + @loggers.first.instance_of?(klass) + end + + def kind_of?(klass) + @loggers.first.is_a?(klass) + end + + def class + @loggers.first.class + end + def method_missing(name, *args, &block) # Some libraries will do stuff like Library.logger.formatter = Rails.logger.formatter # As such, we should return the first logger's (the original logger) return value.