From 3a24eb900dfd297d7876a8ddc7a968b8163bd3b5 Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 26 Nov 2010 13:02:52 -0500 Subject: [PATCH] Refine log lines --- app/controllers/comments_controller.rb | 2 +- app/controllers/registrations_controller.rb | 2 +- app/controllers/status_messages_controller.rb | 2 +- app/helpers/sockets_helper.rb | 4 ++-- app/models/person.rb | 2 +- app/models/user.rb | 8 +++---- lib/diaspora/user/connecting.rb | 4 ++-- lib/diaspora/user/receiving.rb | 23 ++++++++----------- lib/em-webfinger.rb | 2 +- 9 files changed, 23 insertions(+), 26 deletions(-) diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index b16cec41f..51cdf7bae 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -15,7 +15,7 @@ class CommentsController < ApplicationController @comment = current_user.comment(text, :on => target) if target 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| format.js{ render :json => { :post_id => @comment.post_id, diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 49c6298ec..4eb80fa59 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -11,7 +11,7 @@ class RegistrationsController < Devise::RegistrationsController flash[:notice] = I18n.t 'registrations.create.success' @user.seed_aspects 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 flash[:error] = @user.errors.full_messages.join(', ') Rails.logger.info("event=registration status=failure errors='#{@user.errors.full_messages.join(', ')}'") diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb index 9a442c037..abbd28223 100644 --- a/app/controllers/status_messages_controller.rb +++ b/app/controllers/status_messages_controller.rb @@ -73,7 +73,7 @@ class StatusMessagesController < ApplicationController @status_message.destroy 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 respond_with :location => root_url diff --git a/app/helpers/sockets_helper.rb b/app/helpers/sockets_helper.rb index e83bb7c27..cbe0ee875 100644 --- a/app/helpers/sockets_helper.rb +++ b/app/helpers/sockets_helper.rb @@ -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 end 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 end action_hash = {:class =>object.class.to_s.underscore.pluralize, :html => v, :post_id => obj_id(object)} @@ -46,7 +46,7 @@ module SocketsHelper begin render_to_string(:partial => 'shared/notification', :locals => {:object => object}) 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 diff --git a/app/models/person.rb b/app/models/person.rb index f0da52941..9a9fda03b 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -125,7 +125,7 @@ class Person new_person.url = profile.seed_location #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.profile = Profile.new( :first_name => hcard[:given_name], :last_name => hcard[:family_name], diff --git a/app/models/user.rb b/app/models/user.rb index 520cbc77c..002c01cd1 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -164,7 +164,7 @@ class User aspect_ids = validate_aspect_permissions(aspect_ids) self.raw_visible_posts << post 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) post.socket_to_uid(id, :aspect_ids => aspect_ids) if post.respond_to?(:socket_to_uid) && !post.pending if post.public @@ -285,20 +285,20 @@ class User if comment.save comment 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 end end def dispatch_comment(comment) 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.save aspects = aspects_with_post(comment.post_id) push_to_people(comment, people_in_aspects(aspects)) 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 push_to_people comment, [comment.post.person] end diff --git a/lib/diaspora/user/connecting.rb b/lib/diaspora/user/connecting.rb index a3ad5fd22..89f3fb9ab 100644 --- a/lib/diaspora/user/connecting.rb +++ b/lib/diaspora/user/connecting.rb @@ -88,7 +88,7 @@ module Diaspora end 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) push_to_people retraction, [bad_contact] remove_contact(bad_contact) @@ -119,7 +119,7 @@ module Diaspora end 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 end diff --git a/lib/diaspora/user/receiving.rb b/lib/diaspora/user/receiving.rb index 13b2f3352..58266c5b7 100644 --- a/lib/diaspora/user/receiving.rb +++ b/lib/diaspora/user/receiving.rb @@ -22,7 +22,7 @@ module Diaspora def receive xml, salmon_author 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) salmon_author.save @@ -36,7 +36,7 @@ module Diaspora end 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 end @@ -46,11 +46,11 @@ module Diaspora if person.class == Person object.person = person if object.respond_to? :person= 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 else 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 end end @@ -75,10 +75,9 @@ module Diaspora def receive_retraction retraction if retraction.type == 'Person' 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 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) else retraction.perform self.id @@ -103,14 +102,12 @@ module Diaspora def receive_comment comment 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 end self.visible_people = self.visible_people | [comment.person] self.save - Rails.logger.debug("The person parsed from comment xml is #{comment.person.inspect}") unless comment.person.nil? comment.person.save - Rails.logger.debug("From: #{comment.person.inspect}") if comment.person comment.save! unless owns?(comment) dispatch_comment comment @@ -138,19 +135,19 @@ module Diaspora if known_post.mutable? known_post.update_attributes(post.to_mongo) 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 elsif on_pod == post 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 end elsif !on_pod 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 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 diff --git a/lib/em-webfinger.rb b/lib/em-webfinger.rb index c63f9575b..569640605 100644 --- a/lib/em-webfinger.rb +++ b/lib/em-webfinger.rb @@ -92,7 +92,7 @@ class EMWebfinger 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| begin c.call(person)