tinker with log messages for readability

This commit is contained in:
Florian Staudacher 2012-06-15 01:22:50 +02:00
parent 8f21657179
commit bff069ab19
2 changed files with 12 additions and 12 deletions

View file

@ -28,7 +28,7 @@ class Postzord::Receiver::Private < Postzord::Receiver
end end
rescue => e rescue => e
#this sucks #this sucks
FEDERATION_LOGGER.info("Failure to receive #{@object.inspect} for sender:#{@sender.id} for user:#{@user.id}: #{e.message}") FEDERATION_LOGGER.error("Failure to receive #{@object.class} from sender:#{@sender.id} for user:#{@user.id}: #{e.message}\n#{@object.inspect}")
raise e raise e
end end
end end
@ -42,9 +42,9 @@ class Postzord::Receiver::Private < Postzord::Receiver
if self.validate_object if self.validate_object
set_author! set_author!
receive_object receive_object
FEDERATION_LOGGER.info("object received #{@object.class}") FEDERATION_LOGGER.info("object received: [#{@object.class}#{@object.respond_to?(:text) ? ":'#{@object.text}'" : ''}]")
else else
FEDERATION_LOGGER.info("failed to receive object from #{@object.author}: #{@object.inspect}") FEDERATION_LOGGER.error("failed to receive object from #{@object.author}: #{@object.inspect}")
raise "not a valid object:#{@object.inspect}" raise "not a valid object:#{@object.inspect}"
end end
end end
@ -53,7 +53,7 @@ class Postzord::Receiver::Private < Postzord::Receiver
def receive_object def receive_object
obj = @object.receive(@user, @author) obj = @object.receive(@user, @author)
Notification.notify(@user, obj, @author) if obj.respond_to?(:notification_type) 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.inspect}") FEDERATION_LOGGER.info("user:#{@user.id} successfully received private post from person #{@sender.guid}: #{@object.inspect}")
obj obj
end end
@ -95,21 +95,21 @@ class Postzord::Receiver::Private < Postzord::Receiver
#validations #validations
def relayable_without_parent? def relayable_without_parent?
if @object.respond_to?(:relayable?) && @object.parent.nil? if @object.respond_to?(:relayable?) && @object.parent.nil?
FEDERATION_LOGGER.info("event=receive status=abort reason='received a comment but no corresponding post' recipient=#{@user_person.diaspora_handle} sender=#{@sender.diaspora_handle} payload_type=#{@object.class})") FEDERATION_LOGGER.error("event=receive status=abort reason='received a comment but no corresponding post' recipient=#{@user_person.diaspora_handle} sender=#{@sender.diaspora_handle} payload_type=#{@object.class})")
return true return true
end end
end end
def author_does_not_match_xml_author? def author_does_not_match_xml_author?
if (@author.diaspora_handle != xml_author) if (@author.diaspora_handle != xml_author)
FEDERATION_LOGGER.info("event=receive status=abort reason='author in xml does not match retrieved person' payload_type=#{@object.class} recipient=#{@user_person.diaspora_handle} sender=#{@sender.diaspora_handle}") FEDERATION_LOGGER.error("event=receive status=abort reason='author in xml does not match retrieved person' payload_type=#{@object.class} recipient=#{@user_person.diaspora_handle} sender=#{@sender.diaspora_handle}")
return true return true
end end
end end
def contact_required_unless_request def contact_required_unless_request
unless @object.is_a?(Request) || @user.contact_for(@sender) unless @object.is_a?(Request) || @user.contact_for(@sender)
FEDERATION_LOGGER.info("event=receive status=abort reason='sender not connected to recipient' recipient=#{@user_person.diaspora_handle} sender=#{@sender.diaspora_handle}") FEDERATION_LOGGER.error("event=receive status=abort reason='sender not connected to recipient' recipient=#{@user_person.diaspora_handle} sender=#{@sender.diaspora_handle}")
return true return true
end end
end end

View file

@ -2,12 +2,12 @@ require Rails.root.join('lib', 'hcard')
require Rails.root.join('lib', 'webfinger_profile') require Rails.root.join('lib', 'webfinger_profile')
class Webfinger class Webfinger
attr_accessor :host_meta_xrd, :webfinger_profile_xrd, attr_accessor :host_meta_xrd, :webfinger_profile_xrd,
:webfinger_profile, :hcard, :hcard_xrd, :person, :webfinger_profile, :hcard, :hcard_xrd, :person,
:account, :ssl :account, :ssl
def initialize(account) def initialize(account)
self.account = account self.account = account
self.ssl = true self.ssl = true
end end
@ -56,7 +56,7 @@ class Webfinger
else else
person = make_person_from_webfinger person = make_person_from_webfinger
end end
FEDERATION_LOGGER.info("successfully webfingered#{@account}") if person FEDERATION_LOGGER.info("successfully webfingered #{@account}") if person
person person
end end
@ -95,7 +95,7 @@ class Webfinger
def webfinger_profile_xrd def webfinger_profile_xrd
@webfinger_profile_xrd ||= get(webfinger_profile_url) @webfinger_profile_xrd ||= get(webfinger_profile_url)
FEDERATION_LOGGER.info "#{@account} doesn't exists anymore" if @webfinger_profile_xrd == false FEDERATION_LOGGER.warn "#{@account} doesn't exists anymore" if @webfinger_profile_xrd == false
@webfinger_profile_xrd @webfinger_profile_xrd
end end