fix logging to work great with non-persisted objects

This commit is contained in:
Maxwell Salzberg 2012-02-17 14:59:42 -08:00
parent 28504f09bb
commit 90452744fc
6 changed files with 12 additions and 50 deletions

View file

@ -15,8 +15,10 @@ module Jobs
begin
yield
rescue Exception => e
FEDERATION_LOGGER.info(e.message)
raise e
Rails.info("error in job: #{e.message}")
unless DUMB_ERROR_MESSAGES.include?(e.message)
raise e
end
end
end
end

View file

@ -1,39 +0,0 @@
# Copyright (c) 2010-2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
Diaspora::Application.configure do
# Settings specified here will take precedence over those in config/environment.rb
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the webserver when you make code changes.
config.cache_classes = false
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
# Show full error reports and disable caching
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false
config.active_support.deprecation = :log
config.threadsafe!
# Monkeypatch around the nasty "2.5MB exception page" issue, caused by very large environment vars
# This snippet via: http://stackoverflow.com/questions/3114993/exception-pages-in-development-mode-take-upwards-of-15-30-seconds-to-render-why
# Relevant Rails ticket: https://rails.lighthouseapp.com/projects/8994/tickets/5027-_request_and_responseerb-and-diagnosticserb-take-an-increasingly-long-time-to-render-in-development-with-multiple-show-tables-calls
config.after_initialize do
module SmallInspect
def inspect
"<#{self.class.name} - tooooo long>"
end
end
[ActionController::Base, ActionDispatch::RemoteIp::RemoteIpGetter, OmniAuth::Strategy, Warden::Proxy].each do |klazz|
klazz.send(:include, SmallInspect)
end
end
end

View file

@ -14,7 +14,7 @@ class Postzord::Receiver::LocalBatch < Postzord::Receiver
end
def receive!
FEDERATION_LOGGER.info("receiving local batch for #{@object.class}:#{@object.guid}")
FEDERATION_LOGGER.info("receiving local batch for #{@object.inspect}")
if @object.respond_to?(:relayable?)
receive_relayable
else
@ -25,7 +25,7 @@ class Postzord::Receiver::LocalBatch < Postzord::Receiver
# 09/27/11 this is slow
notify_users
FEDERATION_LOGGER.info("receiving local batch completed for #{@object.class}:#{@object.guid}")
FEDERATION_LOGGER.info("receiving local batch completed for #{@object.inspect}")
true
end

View file

@ -28,7 +28,7 @@ class Postzord::Receiver::Private < Postzord::Receiver
end
rescue Exception => e
#this sucks
FEDERATION_LOGGER.info("Failure to receive #{@object.class}:#{@object.id} for sender:#{@sender.id} for user:#{@user.id}: #{e.message}")
FEDERATION_LOGGER.info("Failure to receive #{@object.inspect} for sender:#{@sender.id} for user:#{@user.id}: #{e.message}")
raise e
end
end
@ -53,7 +53,7 @@ class Postzord::Receiver::Private < Postzord::Receiver
def receive_object
obj = @object.receive(@user, @author)
Notification.notify(@user, obj, @author) if obj.respond_to?(:notification_type)
FEDERATION_LOGGER.info("user:#{@user.id} successfully received private post from person#{@sender.guid} #{@object.class}:#{@object.guid}")
FEDERATION_LOGGER.info("user:#{@user.id} successfully received private post from person#{@sender.guid} #{@object.inspect}")
obj
end

View file

@ -20,16 +20,15 @@ class Postzord::Receiver::Public < Postzord::Receiver
# @return [void]
def receive!
raise 'not valid signature' unless verified_signature?
raise 'unable to save object' unless save_object
return false unless verified_signature?
return false unless save_object
FEDERATION_LOGGER.info("received a #{@object.class}:#{@object.guid} with author #{@object.author.diaspora_handle}")
FEDERATION_LOGGER.info("received a #{@object.inspect}")
if @object.respond_to?(:relayable?)
receive_relayable
elsif @object.is_a?(AccountDeletion)
#nothing
else
FEDERATION_LOGGER.info("queuing local batchjob")
Resque.enqueue(Jobs::ReceiveLocalBatch, @object.class.to_s, @object.id, self.recipient_user_ids)
true
end

View file

@ -51,7 +51,7 @@ class Webfinger
else
person = make_person_from_webfinger
end
FEDERATION_LOGGER.logger.info("successfully webfingered#{@account}")
FEDERATION_LOGGER.info("successfully webfingered#{@account}")
person
end