diff --git a/bin/rapns b/bin/rapns index bd82125..70a0893 100755 --- a/bin/rapns +++ b/bin/rapns @@ -34,4 +34,6 @@ load 'config/initializers/rapns.rb' if File.exist?('config/initializers/rapns.rb Rapns.config.update(config) Rapns.require_for_daemon +ActiveRecord::Base.logger = Rapns.logger if Rapns.config.intercept_active_record_logger + Rapns::Daemon.start diff --git a/lib/generators/templates/rapns.rb b/lib/generators/templates/rapns.rb index efc2721..58de14b 100644 --- a/lib/generators/templates/rapns.rb +++ b/lib/generators/templates/rapns.rb @@ -26,6 +26,9 @@ # Define a custom logger. # config.logger = MyLogger.new + # Set ActiveRecord logger to Rapns.logger. + # config.intercept_active_record_logger = false + end Rapns.reflect do |on| diff --git a/lib/rapns/configuration.rb b/lib/rapns/configuration.rb index 249302d..13ba7e7 100644 --- a/lib/rapns/configuration.rb +++ b/lib/rapns/configuration.rb @@ -9,7 +9,7 @@ def self.configure CONFIG_ATTRS = [:foreground, :push_poll, :feedback_poll, :embedded, :airbrake_notify, :check_for_errors, :pid_file, :batch_size, - :push, :store, :logger, :batch_storage_updates] + :push, :store, :logger, :batch_storage_updates, :intercept_active_record_logger] class ConfigurationWithoutDefaults < Struct.new(*CONFIG_ATTRS) end @@ -80,6 +80,7 @@ def set_defaults self.store = :active_record self.logger = nil self.batch_storage_updates = true + self.intercept_active_record_logger = false # Internal options. self.embedded = false diff --git a/lib/rapns/logger.rb b/lib/rapns/logger.rb index 8b14421..ba96521 100644 --- a/lib/rapns/logger.rb +++ b/lib/rapns/logger.rb @@ -27,6 +27,14 @@ def warn(msg) log(:warn, msg, 'WARNING', STDERR) end + def debug(msg) + log(:debug, msg) + end + + def debug? + Rails.configuration.log_level == :debug + end + private def setup_logger(log)