Refine log lines

This commit is contained in:
Raphael 2010-11-26 13:02:52 -05:00
parent 6e5b097f81
commit 3a24eb900d
9 changed files with 23 additions and 26 deletions

View file

@ -15,7 +15,7 @@ class CommentsController < ApplicationController
@comment = current_user.comment(text, :on => target) if target @comment = current_user.comment(text, :on => target) if target
if @comment if @comment
Rails.logger.info("event=comment_create user=#{current_user.diaspora_handle} status=success comment=#{@comment.inspect}") Rails.logger.info("event=comment_create user=#{current_user.diaspora_handle} status=success comment=#{@comment.id}")
respond_to do |format| respond_to do |format|
format.js{ render :json => { :post_id => @comment.post_id, format.js{ render :json => { :post_id => @comment.post_id,

View file

@ -11,7 +11,7 @@ class RegistrationsController < Devise::RegistrationsController
flash[:notice] = I18n.t 'registrations.create.success' flash[:notice] = I18n.t 'registrations.create.success'
@user.seed_aspects @user.seed_aspects
sign_in_and_redirect(:user, @user) sign_in_and_redirect(:user, @user)
Rails.logger.info("event=registration status=successful user=#{@user.inspect}") Rails.logger.info("event=registration status=successful user=#{@user.diaspora_handle}")
else else
flash[:error] = @user.errors.full_messages.join(', ') flash[:error] = @user.errors.full_messages.join(', ')
Rails.logger.info("event=registration status=failure errors='#{@user.errors.full_messages.join(', ')}'") Rails.logger.info("event=registration status=failure errors='#{@user.errors.full_messages.join(', ')}'")

View file

@ -73,7 +73,7 @@ class StatusMessagesController < ApplicationController
@status_message.destroy @status_message.destroy
else else
Rails.logger.info "#{current_user.inspect} is trying to delete a post they don't own with id: #{params[:id]}" Rails.logger.info "event=post_destroy status=failure user=#{current_user.diaspora_handle} reason='User does not own post'"
end end
respond_with :location => root_url respond_with :location => root_url

View file

@ -22,7 +22,7 @@ module SocketsHelper
v = render_to_string(:partial => type_partial(object), :locals => {:post => object, :current_user => user}) unless object.is_a? Retraction v = render_to_string(:partial => type_partial(object), :locals => {:post => object, :current_user => user}) unless object.is_a? Retraction
end end
rescue Exception => e rescue Exception => e
Rails.logger.error("web socket view rendering failed for object #{object.inspect}.") Rails.logger.error("event=socket_render status=fail user=#{user.diaspora_handle} object=#{object.id.to_s}")
raise e raise e
end end
action_hash = {:class =>object.class.to_s.underscore.pluralize, :html => v, :post_id => obj_id(object)} action_hash = {:class =>object.class.to_s.underscore.pluralize, :html => v, :post_id => obj_id(object)}
@ -46,7 +46,7 @@ module SocketsHelper
begin begin
render_to_string(:partial => 'shared/notification', :locals => {:object => object}) render_to_string(:partial => 'shared/notification', :locals => {:object => object})
rescue Exception => e rescue Exception => e
Rails.logger.error("web socket notification failed for object #{object.inspect}.") Rails.logger.error("event=socket_render status=fail user=#{user.diaspora_handle} object=#{object.id.to_s}")
end end
end end
end end

View file

@ -125,7 +125,7 @@ class Person
new_person.url = profile.seed_location new_person.url = profile.seed_location
#hcard_profile = HCard.find profile.hcard.first[:href] #hcard_profile = HCard.find profile.hcard.first[:href]
Rails.logger.info("hcard: #{ hcard.inspect}") Rails.logger.info("event=webfinger_marshal valid=#{new_person.valid?} target=#{new_person.diaspora_handle}")
new_person.url = hcard[:url] new_person.url = hcard[:url]
new_person.profile = Profile.new( :first_name => hcard[:given_name], new_person.profile = Profile.new( :first_name => hcard[:given_name],
:last_name => hcard[:family_name], :last_name => hcard[:family_name],

View file

@ -164,7 +164,7 @@ class User
aspect_ids = validate_aspect_permissions(aspect_ids) aspect_ids = validate_aspect_permissions(aspect_ids)
self.raw_visible_posts << post self.raw_visible_posts << post
self.save self.save
Rails.logger.info("Pushing: #{post.inspect} out to aspects") Rails.logger.info("event=dispatch user=#{diaspora_handle} post=#{post.id.to_s}")
push_to_aspects(post, aspect_ids) push_to_aspects(post, aspect_ids)
post.socket_to_uid(id, :aspect_ids => aspect_ids) if post.respond_to?(:socket_to_uid) && !post.pending post.socket_to_uid(id, :aspect_ids => aspect_ids) if post.respond_to?(:socket_to_uid) && !post.pending
if post.public if post.public
@ -285,20 +285,20 @@ class User
if comment.save if comment.save
comment comment
else else
Rails.logger.warn "event=build_comment status=save_failure user=#{self.diaspora_handle} comment=#{comment.inspect}" Rails.logger.warn "event=build_comment status=save_failure user=#{self.diaspora_handle} comment=#{comment.id}"
false false
end end
end end
def dispatch_comment(comment) def dispatch_comment(comment)
if owns? comment.post if owns? comment.post
Rails.logger.info "event=dispatch_comment direction=downstream user=#{self.diaspora_handle} comment=#{comment.inspect}" Rails.logger.info "event=dispatch_comment direction=downstream user=#{self.diaspora_handle} comment=#{comment.id}"
comment.post_creator_signature = comment.sign_with_key(encryption_key) comment.post_creator_signature = comment.sign_with_key(encryption_key)
comment.save comment.save
aspects = aspects_with_post(comment.post_id) aspects = aspects_with_post(comment.post_id)
push_to_people(comment, people_in_aspects(aspects)) push_to_people(comment, people_in_aspects(aspects))
elsif owns? comment elsif owns? comment
Rails.logger.info "event=dispatch_comment direction=upstream user=#{self.diaspora_handle} comment=#{comment.inspect}" Rails.logger.info "event=dispatch_comment direction=upstream user=#{self.diaspora_handle} comment=#{comment.id}"
comment.save comment.save
push_to_people comment, [comment.post.person] push_to_people comment, [comment.post.person]
end end

View file

@ -88,7 +88,7 @@ module Diaspora
end end
def disconnect(bad_contact) def disconnect(bad_contact)
Rails.logger.info("#{self.real_name} is disconnecting #{bad_contact.inspect}") Rails.logger.info("event=disconnect user=#{diaspora_handle} target=#{bad_contact.diaspora_handle}")
retraction = Retraction.for(self) retraction = Retraction.for(self)
push_to_people retraction, [bad_contact] push_to_people retraction, [bad_contact]
remove_contact(bad_contact) remove_contact(bad_contact)
@ -119,7 +119,7 @@ module Diaspora
end end
def disconnected_by(bad_contact) def disconnected_by(bad_contact)
Rails.logger.info("#{self.real_name} is being disconnected by #{bad_contact.inspect}") Rails.logger.info("event=disconnected_by user=#{diaspora_handle} target=#{bad_contact.diaspora_handle}")
remove_contact bad_contact remove_contact bad_contact
end end

View file

@ -22,7 +22,7 @@ module Diaspora
def receive xml, salmon_author def receive xml, salmon_author
object = Diaspora::Parser.from_xml(xml) object = Diaspora::Parser.from_xml(xml)
Rails.logger.info("event=receive status=start recipient=#{self.diaspora_handle} payload_type=#{object.class} payload=#{object.inspect} sender=#{salmon_author.diaspora_handle}") Rails.logger.info("event=receive status=start recipient=#{self.diaspora_handle} payload_type=#{object.class} sender=#{salmon_author.diaspora_handle}")
if object.is_a?(Request) if object.is_a?(Request)
salmon_author.save salmon_author.save
@ -36,7 +36,7 @@ module Diaspora
end end
if (salmon_author.diaspora_handle != xml_author) if (salmon_author.diaspora_handle != xml_author)
Rails.logger.info("event=receive status=abort reason='author in xml does not match retrieved person' payload_type=#{object.class} recipient=#{self.diaspora_handle} sender=#{salmon_author.diaspora_handle} payload=#{object.inspect}") Rails.logger.info("event=receive status=abort reason='author in xml does not match retrieved person' payload_type=#{object.class} recipient=#{self.diaspora_handle} sender=#{salmon_author.diaspora_handle}")
return return
end end
@ -46,11 +46,11 @@ module Diaspora
if person.class == Person if person.class == Person
object.person = person if object.respond_to? :person= object.person = person if object.respond_to? :person=
unless object.is_a?(Request) || self.contact_for(salmon_author) unless object.is_a?(Request) || self.contact_for(salmon_author)
Rails.logger.info("event=receive status=abort reason='sender not connected to recipient' recipient=#{self.diaspora_handle} sender=#{salmon_author.diaspora_handle} payload=#{object.inspect} payload_type=#{object.class}") Rails.logger.info("event=receive status=abort reason='sender not connected to recipient' recipient=#{self.diaspora_handle} sender=#{salmon_author.diaspora_handle} payload_type=#{object.class}")
return return
else else
receive_object(object,person) receive_object(object,person)
Rails.logger.info("event=receive status=complete recipient=#{self.diaspora_handle} sender=#{salmon_author.diaspora_handle} payload=#{object.inspect} payload_type#{object.class}") Rails.logger.info("event=receive status=complete recipient=#{self.diaspora_handle} sender=#{salmon_author.diaspora_handle} payload_type#{object.class}")
return object return object
end end
end end
@ -75,10 +75,9 @@ module Diaspora
def receive_retraction retraction def receive_retraction retraction
if retraction.type == 'Person' if retraction.type == 'Person'
unless retraction.person.id.to_s == retraction.post_id.to_s unless retraction.person.id.to_s == retraction.post_id.to_s
Rails.logger.info("event=receive status=abort reason='sender is not the person he is trying to retract' recipient=#{self.diaspora_handle} sender=#{salmon_author.diaspora_handle} payload=#{retraction.inspect} payload_type=#{retraction.class} retraction_type=person") Rails.logger.info("event=receive status=abort reason='sender is not the person he is trying to retract' recipient=#{self.diaspora_handle} sender=#{salmon_author.diaspora_handle} payload_type=#{retraction.class} retraction_type=person")
return return
end end
Rails.logger.info( "the person id is #{retraction.post_id} the contact found is #{visible_person_by_id(retraction.post_id).inspect}")
disconnected_by visible_person_by_id(retraction.post_id) disconnected_by visible_person_by_id(retraction.post_id)
else else
retraction.perform self.id retraction.perform self.id
@ -103,14 +102,12 @@ module Diaspora
def receive_comment comment def receive_comment comment
unless comment.post.person == self.person || comment.verify_post_creator_signature unless comment.post.person == self.person || comment.verify_post_creator_signature
Rails.logger.info("event=receive status=abort reason='comment signature not valid' recipient=#{self.diaspora_handle} sender=#{salmon_author.diaspora_handle} payload=#{comment.inspect} payload_type=#{comment.class}") Rails.logger.info("event=receive status=abort reason='comment signature not valid' recipient=#{self.diaspora_handle} sender=#{salmon_author.diaspora_handle} payload_type=#{comment.class} post_id=#{comment.post_id}")
return return
end end
self.visible_people = self.visible_people | [comment.person] self.visible_people = self.visible_people | [comment.person]
self.save self.save
Rails.logger.debug("The person parsed from comment xml is #{comment.person.inspect}") unless comment.person.nil?
comment.person.save comment.person.save
Rails.logger.debug("From: #{comment.person.inspect}") if comment.person
comment.save! comment.save!
unless owns?(comment) unless owns?(comment)
dispatch_comment comment dispatch_comment comment
@ -138,19 +135,19 @@ module Diaspora
if known_post.mutable? if known_post.mutable?
known_post.update_attributes(post.to_mongo) known_post.update_attributes(post.to_mongo)
else else
Rails.logger.info("event=receive payload_type=#{post.class} update=true status=abort sender=#{post.diaspora_handle} reason=immutable updated_post=#{post.inspect} existing_post=#{known_post.inspect}") Rails.logger.info("event=receive payload_type=#{post.class} update=true status=abort sender=#{post.diaspora_handle} reason=immutable existing_post=#{known_post.id}")
end end
elsif on_pod == post elsif on_pod == post
update_user_refs_and_add_to_aspects(on_pod) update_user_refs_and_add_to_aspects(on_pod)
Rails.logger.info("event=receive payload_type=#{post.class} update=true status=complete sender=#{post.diaspora_handle} payload=#{post.inspect} existing_post=#{known_post.inspect}") Rails.logger.info("event=receive payload_type=#{post.class} update=true status=complete sender=#{post.diaspora_handle} existing_post=#{known_post.id}")
post post
end end
elsif !on_pod elsif !on_pod
update_user_refs_and_add_to_aspects(post) update_user_refs_and_add_to_aspects(post)
Rails.logger.info("event=receive payload_type=#{post.class} update=false status=complete sender=#{post.diaspora_handle} payload=#{post.inspect}") Rails.logger.info("event=receive payload_type=#{post.class} update=false status=complete sender=#{post.diaspora_handle}")
post post
else else
Rails.logger.info("event=receive payload_type=#{post.class} update=true status=abort sender=#{post.diaspora_handle} reason='update not from post owner' updated_post=#{post.inspect} existing_post=#{known_post.inspect}") Rails.logger.info("event=receive payload_type=#{post.class} update=true status=abort sender=#{post.diaspora_handle} reason='update not from post owner' existing_post=#{known_post.id}")
end end
end end

View file

@ -92,7 +92,7 @@ class EMWebfinger
def process_callbacks(person) def process_callbacks(person)
Rails.logger.info("event=EMWebfinger status=callbacks_started target=#{@account} response=#{person.inspect}") Rails.logger.info("event=EMWebfinger status=callbacks_started target=#{@account} response='#{person.is_a?(String) ? person : person.id}'")
@callbacks.each { |c| @callbacks.each { |c|
begin begin
c.call(person) c.call(person)