Use single log method

Andrew committed Feb 27, 2018
commit 816f304c5779c8084050d9047c26400ff5ea89d5
Showing 3 changed files with 7 additions and 3 deletions
ahoy.rb b/lib/ahoy.rb +4 -0
@@ @@ -66,6 +66,10 @@ module Ahoy
mattr_accessor :token_generator
self.token_generator = -> { SecureRandom.uuid }
+
+ def self.log(message)
+ Rails.logger.info { "[ahoy] #{message}" }
+ end
end
ActiveSupport.on_load(:action_controller) do
ahoy/database_store.rb b/lib/ahoy/database_store.rb +2 -2
@@ @@ -20,7 +20,7 @@ module Ahoy
raise e unless unique_exception?(e)
end
else
- Rails.logger.warn "[ahoy] Event excluded since visit not created: #{data[:visit_token]}"
+ Ahoy.log "Event excluded since visit not created: #{data[:visit_token]}"
end
end
@@ @@ -32,7 +32,7 @@ module Ahoy
elsif visit
visit.update_attributes(data)
else
- Rails.logger.warn "[ahoy] Visit for geocode not found: #{data[:visit_token]}"
+ Ahoy.log "Visit for geocode not found: #{data[:visit_token]}"
end
end
ahoy/tracker.rb b/lib/ahoy/tracker.rb +1 -1
@@ @@ -256,7 +256,7 @@ module Ahoy
end
def debug(message)
- Rails.logger.debug { "[ahoy] #{message}" }
+ Ahoy.log message
end
end
end