replace Rails.logger with logging-logger

closes #6041
This commit is contained in:
Benjamin Neff 2015-06-04 00:11:10 +02:00 committed by Dennis Schubert
parent b6c46b3fc4
commit 27b4a44e4a
29 changed files with 95 additions and 69 deletions

View file

@ -25,6 +25,7 @@
* Increase post titles length to 50 and use configured pod name as title in the atom feed [#6020](https://github.com/diaspora/diaspora/pull/6020) * Increase post titles length to 50 and use configured pod name as title in the atom feed [#6020](https://github.com/diaspora/diaspora/pull/6020)
* Remove deprecated Facebook permissions [#6019](https://github.com/diaspora/diaspora/pull/6019) * Remove deprecated Facebook permissions [#6019](https://github.com/diaspora/diaspora/pull/6019)
* Make used post title lengths more consistent [#6022](https://github.com/diaspora/diaspora/pull/6022) * Make used post title lengths more consistent [#6022](https://github.com/diaspora/diaspora/pull/6022)
* Improved logging source [#6041](https://github.com/diaspora/diaspora/pull/6041)
## Bug fixes ## Bug fixes
* Disable auto follow back on aspect deletion [#5846](https://github.com/diaspora/diaspora/pull/5846) * Disable auto follow back on aspect deletion [#5846](https://github.com/diaspora/diaspora/pull/5846)

View file

@ -15,7 +15,8 @@ class MessagesController < ApplicationController
message = current_user.build_message(conversation, opts) message = current_user.build_message(conversation, opts)
if message.save if message.save
Rails.logger.info("event=create type=comment user=#{current_user.diaspora_handle} status=success message=#{message.id} chars=#{params[:message][:text].length}") logger.info "event=create type=comment user=#{current_user.diaspora_handle} status=success " \
"message=#{message.id} chars=#{params[:message][:text].length}"
Postzord::Dispatcher.build(current_user, message).post Postzord::Dispatcher.build(current_user, message).post
else else
flash[:error] = I18n.t('conversations.new_conversation.fail') flash[:error] = I18n.t('conversations.new_conversation.fail')

View file

@ -15,12 +15,12 @@ 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.diaspora_handle}") logger.info "event=registration status=successful user=#{@user.diaspora_handle}"
else else
@user.errors.delete(:person) @user.errors.delete(:person)
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(', ')}'") logger.info "event=registration status=failure errors='#{@user.errors.full_messages.join(', ')}'"
render :action => 'new', :layout => 'with_header' render :action => 'new', :layout => 'with_header'
end end
end end

View file

@ -32,7 +32,7 @@ class ServicesController < ApplicationController
end end
def failure def failure
Rails.logger.info "error in oauth #{params.inspect}" logger.info "error in oauth #{params.inspect}"
flash[:error] = t('services.failure.error') flash[:error] = t('services.failure.error')
redirect_to services_url redirect_to services_url
end end

View file

@ -53,7 +53,7 @@ module NotificationMailers
" recipient_handle=#{@recipient.diaspora_handle}" " recipient_handle=#{@recipient.diaspora_handle}"
log_string << " sender_handle=#{@sender.diaspora_handle}" if sender_id.present? log_string << " sender_handle=#{@sender.diaspora_handle}" if sender_id.present?
logger.info(log_string) logger.info log_string
end end
end end
end end

View file

@ -13,7 +13,7 @@ class Mention < ActiveRecord::Base
after_destroy :delete_notification after_destroy :delete_notification
def notify_recipient def notify_recipient
Rails.logger.info "event=mention_sent id=#{self.id} to=#{person.diaspora_handle} from=#{post.author.diaspora_handle}" logger.info "event=mention_sent id=#{id} to=#{person.diaspora_handle} from=#{post.author.diaspora_handle}"
Notification.notify(person.owner, self, post.author) unless person.remote? Notification.notify(person.owner, self, post.author) unless person.remote?
end end

View file

@ -261,7 +261,8 @@ class Person < ActiveRecord::Base
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("event=webfinger_marshal valid=#{new_person.valid?} target=#{new_person.diaspora_handle}") ::Logging::Logger[self].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.assign_new_profile_from_hcard(hcard) new_person.assign_new_profile_from_hcard(hcard)
new_person.save! new_person.save!

View file

@ -56,7 +56,7 @@ class Profile < ActiveRecord::Base
def receive(user, person) def receive(user, person)
person.reload # make sure to have old profile referenced person.reload # make sure to have old profile referenced
Rails.logger.info("event=receive payload_type=profile sender=#{person} to=#{user}") logger.info "event=receive payload_type=profile sender=#{person.diaspora_handle} to=#{user.diaspora_handle}"
profiles_attr = self.attributes.merge('tag_string' => self.tag_string).slice('diaspora_handle', 'first_name', 'last_name', 'image_url', 'image_url_small', 'image_url_medium', 'birthday', 'gender', 'bio', 'location', 'searchable', 'nsfw', 'tag_string') profiles_attr = self.attributes.merge('tag_string' => self.tag_string).slice('diaspora_handle', 'first_name', 'last_name', 'image_url', 'image_url_small', 'image_url_medium', 'birthday', 'gender', 'bio', 'location', 'searchable', 'nsfw', 'tag_string')
person.profile.update_attributes(profiles_attr) person.profile.update_attributes(profiles_attr)

View file

@ -9,7 +9,7 @@ class Services::Facebook < Service
end end
def post(post, url='') def post(post, url='')
Rails.logger.debug("event=post_to_service type=facebook sender_id=#{self.user_id}") logger.debug "event=post_to_service type=facebook sender_id=#{user_id} post=#{post.guid}"
response = post_to_facebook("https://graph.facebook.com/me/feed", create_post_params(post).to_param) response = post_to_facebook("https://graph.facebook.com/me/feed", create_post_params(post).to_param)
response = JSON.parse response.body response = JSON.parse response.body
post.facebook_id = response["id"] post.facebook_id = response["id"]
@ -39,7 +39,7 @@ class Services::Facebook < Service
def delete_post(post) def delete_post(post)
if post.present? && post.facebook_id.present? if post.present? && post.facebook_id.present?
Rails.logger.debug("event=delete_from_service type=facebook sender_id=#{self.user_id}") logger.debug "event=delete_from_service type=facebook sender_id=#{user_id} post=#{post.guid}"
delete_from_facebook("https://graph.facebook.com/#{post.facebook_id}/", {:access_token => self.access_token}) delete_from_facebook("https://graph.facebook.com/#{post.facebook_id}/", {:access_token => self.access_token})
end end
end end

View file

@ -43,7 +43,7 @@ class Services::Tumblr < Service
def delete_post(post) def delete_post(post)
if post.present? && post.tumblr_ids.present? if post.present? && post.tumblr_ids.present?
Rails.logger.debug("event=delete_from_service type=tumblr sender_id=#{self.user_id}") logger.debug "event=delete_from_service type=tumblr sender_id=#{user_id} post=#{post.guid}"
tumblr_posts = JSON.parse(post.tumblr_ids) tumblr_posts = JSON.parse(post.tumblr_ids)
tumblr_posts.each do |blog_name,post_id| tumblr_posts.each do |blog_name,post_id|
delete_from_tumblr(blog_name, post_id) delete_from_tumblr(blog_name, post_id)

View file

@ -10,7 +10,7 @@ class Services::Twitter < Service
end end
def post post, url='' def post post, url=''
Rails.logger.debug "event=post_to_service type=twitter sender_id=#{self.user_id}" logger.debug "event=post_to_service type=twitter sender_id=#{user_id} post=#{post.guid}"
tweet = attempt_post post tweet = attempt_post post
post.tweet_id = tweet.id post.tweet_id = tweet.id
post.save post.save
@ -22,7 +22,7 @@ class Services::Twitter < Service
def delete_post post def delete_post post
if post.present? && post.tweet_id.present? if post.present? && post.tweet_id.present?
Rails.logger.debug "event=delete_from_service type=twitter sender_id=#{self.user_id}" logger.debug "event=delete_from_service type=twitter sender_id=#{user_id} post=#{post.guid}"
delete_from_twitter post.tweet_id delete_from_twitter post.tweet_id
end end
end end

View file

@ -53,7 +53,7 @@ module User::Connecting
def disconnect(bad_contact, opts={}) def disconnect(bad_contact, opts={})
person = bad_contact.person person = bad_contact.person
Rails.logger.info("event=disconnect user=#{diaspora_handle} target=#{person.diaspora_handle}") logger.info "event=disconnect user=#{diaspora_handle} target=#{person.diaspora_handle}"
retraction = Retraction.for(self) retraction = Retraction.for(self)
retraction.subscribers = [person]#HAX retraction.subscribers = [person]#HAX
Postzord::Dispatcher.build(self, retraction).post Postzord::Dispatcher.build(self, retraction).post
@ -63,7 +63,7 @@ module User::Connecting
end end
def disconnected_by(person) def disconnected_by(person)
Rails.logger.info("event=disconnected_by user=#{diaspora_handle} target=#{person.diaspora_handle}") logger.info "event=disconnected_by user=#{diaspora_handle} target=#{person.diaspora_handle}"
if contact = self.contact_for(person) if contact = self.contact_for(person)
remove_contact(contact, :retracted => true) remove_contact(contact, :retracted => true)
end end

View file

@ -68,7 +68,7 @@ module User::Querying
end end
def construct_public_followings_sql(opts) def construct_public_followings_sql(opts)
Rails.logger.debug("[EVIL-QUERY] user.construct_public_followings_sql") logger.debug "[EVIL-QUERY] user.construct_public_followings_sql"
# For PostgreSQL and MySQL/MariaDB we use a different query # For PostgreSQL and MySQL/MariaDB we use a different query
# see issue: https://github.com/diaspora/diaspora/issues/5014 # see issue: https://github.com/diaspora/diaspora/issues/5014

View file

@ -1,5 +1,7 @@
module Diaspora module Diaspora
module Encryptable module Encryptable
include Diaspora::Logging
# Check that signature is a correct signature of #signable_string by person # Check that signature is a correct signature of #signable_string by person
# #
# @param [String] signature The signature to be verified. # @param [String] signature The signature to be verified.
@ -7,19 +9,17 @@ module Diaspora
# @return [Boolean] # @return [Boolean]
def verify_signature(signature, person) def verify_signature(signature, person)
if person.nil? if person.nil?
Rails.logger.info("event=verify_signature status=abort reason=no_person guid=#{self.guid}") logger.warn "event=verify_signature status=abort reason=no_person guid=#{guid}"
return false return false
elsif person.public_key.nil? elsif person.public_key.nil?
Rails.logger.info("event=verify_signature status=abort reason=no_key guid=#{self.guid}") logger.warn "event=verify_signature status=abort reason=no_key guid=#{guid}"
return false return false
elsif signature.nil? elsif signature.nil?
Rails.logger.info("event=verify_signature status=abort reason=no_signature guid=#{self.guid}") logger.warn "event=verify_signature status=abort reason=no_signature guid=#{guid}"
return false return false
end end
log_string = "event=verify_signature status=complete guid=#{self.guid}"
validity = person.public_key.verify OpenSSL::Digest::SHA256.new, Base64.decode64(signature), signable_string validity = person.public_key.verify OpenSSL::Digest::SHA256.new, Base64.decode64(signature), signable_string
log_string += " validity=#{validity}" logger.info "event=verify_signature status=complete guid=#{guid} validity=#{validity}"
Rails.logger.info(log_string)
validity validity
end end
@ -27,9 +27,7 @@ module Diaspora
# @return [String] A Base64 encoded signature of #signable_string with key # @return [String] A Base64 encoded signature of #signable_string with key
def sign_with_key(key) def sign_with_key(key)
sig = Base64.strict_encode64(key.sign( OpenSSL::Digest::SHA256.new, signable_string )) sig = Base64.strict_encode64(key.sign( OpenSSL::Digest::SHA256.new, signable_string ))
log_hash = {:event => :sign_with_key, :status => :complete} logger.info "event=sign_with_key status=complete guid=#{guid}"
log_hash.merge(:model_id => self.id) if self.respond_to?(:persisted?)
Rails.logger.info(log_hash)
sig sig
end end

View file

@ -11,7 +11,9 @@
module Diaspora module Diaspora
module Federated module Federated
module Base module Base
include Diaspora::Logging
def self.included(model) def self.included(model)
model.instance_eval do model.instance_eval do
include ROXML include ROXML

View file

@ -30,17 +30,18 @@ class RelayableRetraction < SignedRetraction
end end
def perform receiving_user def perform receiving_user
Rails.logger.debug "Performing relayable retraction for #{target_guid}" logger.debug "Performing relayable retraction for #{target_guid}"
if not self.parent_author_signature.nil? or self.parent.author.remote? if not self.parent_author_signature.nil? or self.parent.author.remote?
# Don't destroy a relayable unless the top-level owner has received it, otherwise it may not get relayed # Don't destroy a relayable unless the top-level owner has received it, otherwise it may not get relayed
self.target.destroy self.target.destroy
Rails.logger.info("event=relayable_retraction status =complete target_type=#{self.target_type} guid =#{self.target_guid}") logger.info "event=relayable_retraction status=complete target_type=#{target_type} guid=#{target_guid}"
end end
end end
def receive(recipient, sender) def receive(recipient, sender)
if self.target.nil? if self.target.nil?
Rails.logger.info("event=retraction status=abort reason='no post found' sender=#{sender.diaspora_handle} target_guid=#{target_guid}") logger.warn "event=retraction status=abort reason='no post found' sender=#{sender.diaspora_handle} " \
"target_guid=#{target_guid}"
return return
elsif self.parent.author == recipient.person && self.target_author_signature_valid? elsif self.parent.author == recipient.person && self.target_author_signature_valid?
#this is a retraction from the downstream object creator, and the recipient is the upstream owner #this is a retraction from the downstream object creator, and the recipient is the upstream owner
@ -51,7 +52,9 @@ class RelayableRetraction < SignedRetraction
#this is a retraction from the upstream owner #this is a retraction from the upstream owner
self.perform(recipient) self.perform(recipient)
else else
Rails.logger.info("event=receive status=abort reason='object signature not valid' recipient=#{recipient.diaspora_handle} sender=#{self.parent.author.diaspora_handle} payload_type=#{self.class} parent_id=#{self.parent.id}") logger.warn "event=receive status=abort reason='object signature not valid' " \
"recipient=#{recipient.diaspora_handle} sender=#{parent.author.diaspora_handle} " \
"payload_type=#{self.class} parent_id=#{parent.id}"
return return
end end
self self

View file

@ -73,7 +73,7 @@ class Request
# @note A [Contact] may already exist if the [Request]'s recipient is sharing with the sender # @note A [Contact] may already exist if the [Request]'s recipient is sharing with the sender
# @return [Request] # @return [Request]
def receive(user, person) def receive(user, person)
Rails.logger.info("event=receive payload_type=request sender=#{self.sender} to=#{self.recipient}") logger.info("event=receive payload_type=request sender=#{sender} to=#{recipient}")
contact = user.contacts.find_or_initialize_by(person_id: self.sender.id) contact = user.contacts.find_or_initialize_by(person_id: self.sender.id)
contact.sharing = true contact.sharing = true

View file

@ -40,24 +40,27 @@ class Retraction
end end
def perform receiving_user def perform receiving_user
Rails.logger.debug "Performing retraction for #{post_guid}" logger.debug "Performing retraction for #{post_guid}"
self.target.destroy if self.target self.target.destroy if self.target
Rails.logger.info("event=retraction status=complete type=#{self.type} guid=#{self.post_guid}") logger.info "event=retraction status=complete type=#{type} guid=#{post_guid}"
end end
def receive(user, person) def receive(user, person)
if self.type == 'Person' if self.type == 'Person'
unless self.person.guid.to_s == self.post_guid.to_s unless self.person.guid.to_s == self.post_guid.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=#{self.person.diaspora_handle} payload_type=#{self.class} retraction_type=person") logger.warn "event=receive status=abort reason='sender is not the person he is trying to retract' " \
"recipient=#{diaspora_handle} sender=#{self.person.diaspora_handle} " \
"payload_type=#{self.class} retraction_type=person"
return return
end end
user.disconnected_by(self.target) user.disconnected_by(self.target)
elsif self.target.nil? || self.target.author != self.person elsif self.target.nil? || self.target.author != self.person
Rails.logger.info("event=retraction status=abort reason='no post found authored by retractor' sender=#{person.diaspora_handle} post_guid=#{post_guid}") logger.warn "event=retraction status=abort reason='no post found authored by retractor' " \
"sender=#{person.diaspora_handle} post_guid=#{post_guid}"
else else
self.perform(user) self.perform(user)
end end
self self
end end
end end

View file

@ -24,6 +24,7 @@ module Diaspora
end end
module InstanceMethods module InstanceMethods
include Diaspora::Logging
def diaspora_handle def diaspora_handle
read_attribute(:diaspora_handle) || self.author.diaspora_handle read_attribute(:diaspora_handle) || self.author.diaspora_handle
end end
@ -52,7 +53,8 @@ module Diaspora
self.receive_non_persisted(user, person) self.receive_non_persisted(user, person)
else else
Rails.logger.info("event=receive payload_type=#{self.class} update=true status=abort sender=#{self.diaspora_handle} reason='update not from shareable owner' existing_shareable=#{self.id}") logger.warn "event=receive payload_type=#{self.class} update=true status=abort " \
"sender=#{diaspora_handle} reason='update not from shareable owner' existing_shareable=#{id}"
false false
end end
end end
@ -88,13 +90,15 @@ module Diaspora
known_shareable.update_attributes(self.attributes.except("id")) known_shareable.update_attributes(self.attributes.except("id"))
true true
else else
Rails.logger.info("event=receive payload_type=#{self.class} update=true status=abort sender=#{self.diaspora_handle} reason=immutable") #existing_shareable=#{known_shareable.id}") logger.warn "event=receive payload_type=#{self.class} update=true status=abort " \
"sender=#{diaspora_handle} reason=immutable existing_shareable=#{known_shareable.id}"
false false
end end
else else
user.contact_for(person).receive_shareable(local_shareable) user.contact_for(person).receive_shareable(local_shareable)
user.notify_if_mentioned(local_shareable) user.notify_if_mentioned(local_shareable)
Rails.logger.info("event=receive payload_type=#{self.class} update=true status=complete sender=#{self.diaspora_handle}") #existing_shareable=#{local_shareable.id}") logger.info "event=receive payload_type=#{self.class} update=true status=complete " \
"sender=#{diaspora_handle} existing_shareable=#{local_shareable.id}"
true true
end end
end end
@ -103,10 +107,12 @@ module Diaspora
if self.save if self.save
user.contact_for(person).receive_shareable(self) user.contact_for(person).receive_shareable(self)
user.notify_if_mentioned(self) user.notify_if_mentioned(self)
Rails.logger.info("event=receive payload_type=#{self.class} update=false status=complete sender=#{self.diaspora_handle}") logger.info "event=receive payload_type=#{self.class} update=false status=complete " \
"sender=#{diaspora_handle}"
true true
else else
Rails.logger.info("event=receive payload_type=#{self.class} update=false status=abort sender=#{self.diaspora_handle} reason=#{self.errors.full_messages}") logger.warn "event=receive payload_type=#{self.class} update=false status=abort " \
"sender=#{diaspora_handle} reason=#{errors.full_messages}"
false false
end end
end end

View file

@ -72,7 +72,7 @@ class SignedRetraction
end end
def perform receiving_user def perform receiving_user
Rails.logger.debug "Performing retraction for #{target_guid}" logger.debug "Performing retraction for #{target_guid}"
if reshare = Reshare.where(:author_id => receiving_user.person.id, :root_guid => target_guid).first if reshare = Reshare.where(:author_id => receiving_user.person.id, :root_guid => target_guid).first
onward_retraction = self.dup onward_retraction = self.dup
onward_retraction.sender = receiving_user.person onward_retraction.sender = receiving_user.person
@ -81,18 +81,20 @@ class SignedRetraction
if target && !target.destroyed? if target && !target.destroyed?
self.target.destroy self.target.destroy
end end
Rails.logger.info("event=retraction status =complete target_type=#{self.target_type} guid =#{self.target_guid}") logger.info "event=retraction status=complete target_type=#{target_type} guid=#{target_guid}"
end end
def receive(recipient, sender) def receive(recipient, sender)
if self.target.nil? if self.target.nil?
Rails.logger.info("event=retraction status=abort reason='no post found' sender=#{sender.diaspora_handle} target_guid=#{target_guid}") logger.warn "event=retraction status=abort reason='no post found' sender=#{sender.diaspora_handle} " \
"target_guid=#{target_guid}"
return return
elsif self.target_author_signature_valid? elsif self.target_author_signature_valid?
#this is a retraction from the upstream owner #this is a retraction from the upstream owner
self.perform(recipient) self.perform(recipient)
else else
Rails.logger.info("event=receive status=abort reason='object signature not valid' recipient=#{recipient.diaspora_handle} sender=#{self.sender_handle} payload_type=#{self.class}") logger.warn "event=receive status=abort reason='object signature not valid' " \
"recipient=#{recipient.diaspora_handle} sender=#{sender_handle} payload_type=#{self.class}"
return return
end end
self self

View file

@ -159,7 +159,9 @@ module Diaspora; module Fetcher; class Public
guid = post['author']['guid'] guid = post['author']['guid']
equal = (guid == @person.guid) equal = (guid == @person.guid)
logger.warn "the author (#{guid}) does not match the person currently being processed (#{@person.guid})" unless equal unless equal
logger.warn "the author (#{guid}) does not match the person currently being processed (#{@person.guid})"
end
equal equal
end end

View file

@ -71,7 +71,8 @@ module Diaspora
# Check to make sure the signature of the comment or like comes from the person claiming to author it # Check to make sure the signature of the comment or like comes from the person claiming to author it
unless comment_or_like.parent_author == user.person || comment_or_like.verify_parent_author_signature unless comment_or_like.parent_author == user.person || comment_or_like.verify_parent_author_signature
Rails.logger.info("event=receive status=abort reason='object signature not valid' recipient=#{user.diaspora_handle} sender=#{self.parent.author.diaspora_handle} payload_type=#{self.class} parent_id=#{self.parent.id}") logger.warn "event=receive status=abort reason='object signature not valid' recipient=#{user.diaspora_handle} "\
"sender=#{parent.author.diaspora_handle} payload_type=#{self.class} parent_id=#{parent.id}"
return return
end end

View file

@ -1,5 +1,7 @@
module EvilQuery module EvilQuery
class Base class Base
include Diaspora::Logging
def fetch_ids!(relation, id_column) def fetch_ids!(relation, id_column)
#the relation should be ordered and limited by here #the relation should be ordered and limited by here
@class.connection.select_values(id_sql(relation, id_column)) @class.connection.select_values(id_sql(relation, id_column))
@ -51,24 +53,24 @@ module EvilQuery
end end
def make_relation! def make_relation!
Rails.logger.debug("[EVIL-QUERY] make_relation!") logger.debug("[EVIL-QUERY] make_relation!")
post_ids = aspects_post_ids! + ids!(followed_tags_posts!) + ids!(mentioned_posts) post_ids = aspects_post_ids! + ids!(followed_tags_posts!) + ids!(mentioned_posts)
post_ids += ids!(community_spotlight_posts!) if @include_spotlight post_ids += ids!(community_spotlight_posts!) if @include_spotlight
Post.where(:id => post_ids) Post.where(:id => post_ids)
end end
def aspects_post_ids! def aspects_post_ids!
Rails.logger.debug("[EVIL-QUERY] aspect_post_ids!") logger.debug("[EVIL-QUERY] aspect_post_ids!")
@user.visible_shareable_ids(Post, :limit => 15, :order => "#{@order} DESC", :max_time => @max_time, :all_aspects? => true, :by_members_of => @user.aspect_ids) @user.visible_shareable_ids(Post, :limit => 15, :order => "#{@order} DESC", :max_time => @max_time, :all_aspects? => true, :by_members_of => @user.aspect_ids)
end end
def followed_tags_posts! def followed_tags_posts!
Rails.logger.debug("[EVIL-QUERY] followed_tags_posts!") logger.debug("[EVIL-QUERY] followed_tags_posts!")
StatusMessage.public_tag_stream(@user.followed_tag_ids) StatusMessage.public_tag_stream(@user.followed_tag_ids)
end end
def mentioned_posts def mentioned_posts
Rails.logger.debug("[EVIL-QUERY] mentioned_posts") logger.debug("[EVIL-QUERY] mentioned_posts")
StatusMessage.where_person_is_mentioned(@user.person) StatusMessage.where_person_is_mentioned(@user.person)
end end

View file

@ -3,6 +3,7 @@
# the COPYRIGHT file. # the COPYRIGHT file.
class HydraWrapper class HydraWrapper
include Diaspora::Logging
OPTS = { OPTS = {
maxredirs: 3, maxredirs: 3,
@ -90,13 +91,8 @@ class HydraWrapper
end end
unless response.success? unless response.success?
message = { logger.warn "event=http_multi_fail sender_id=#{@user.id} url=#{response.effective_url} " \
event: "http_multi_fail", "return_code=#{response.return_code} response_code=#{response.response_code}"
sender_id: @user.id,
url: response.effective_url,
return_code: response.return_code
}
Rails.logger.info message.to_a.map { |k,v| "#{k}=#{v}" }.join(' ')
if @keep_for_retry_proc.call(response) if @keep_for_retry_proc.call(response)
@people_to_retry += people_for_receive_url.map(&:id) @people_to_retry += people_for_receive_url.map(&:id)

View file

@ -4,6 +4,8 @@
class Postzord::Dispatcher class Postzord::Dispatcher
include Diaspora::Logging
require 'postzord/dispatcher/private' require 'postzord/dispatcher/private'
require 'postzord/dispatcher/public' require 'postzord/dispatcher/public'
@ -124,7 +126,8 @@ class Postzord::Dispatcher
batch_deliver_to_local(people) batch_deliver_to_local(people)
else else
people.each do |person| people.each do |person|
Rails.logger.info("event=push route=local sender=#{@sender.diaspora_handle} recipient=#{person.diaspora_handle} payload_type=#{@object.class}") logger.info "event=push route=local sender=#{@sender.diaspora_handle} recipient=#{person.diaspora_handle} " \
"payload_type=#{@object.class}"
Workers::Receive.perform_async(person.owner_id, @xml, @sender.person_id) Workers::Receive.perform_async(person.owner_id, @xml, @sender.person_id)
end end
end end
@ -134,11 +137,12 @@ class Postzord::Dispatcher
def batch_deliver_to_local(people) def batch_deliver_to_local(people)
ids = people.map{ |p| p.owner_id } ids = people.map{ |p| p.owner_id }
Workers::ReceiveLocalBatch.perform_async(@object.class.to_s, @object.id, ids) Workers::ReceiveLocalBatch.perform_async(@object.class.to_s, @object.id, ids)
Rails.logger.info("event=push route=local sender=#{@sender.diaspora_handle} recipients=#{ids.join(',')} payload_type=#{@object.class}") logger.info "event=push route=local sender=#{@sender.diaspora_handle} recipients=#{ids.join(',')} " \
"payload_type=#{@object.class}"
end end
def deliver_to_hub def deliver_to_hub
Rails.logger.debug("event=post_to_service type=pubsub sender_handle=#{@sender.diaspora_handle}") logger.debug "event=post_to_service type=pubsub sender_handle=#{@sender.diaspora_handle}"
Workers::PublishToHub.perform_async(@sender.public_url) Workers::PublishToHub.perform_async(@sender.public_url)
end end

View file

@ -16,7 +16,7 @@ class Postzord::Receiver
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)
logger.info "event=receive status=abort reason='author in xml does not match retrieved person' " \ logger.warn "event=receive status=abort reason='author in xml does not match retrieved person' " \
"payload_type=#{@object.class} sender=#{@author.diaspora_handle}" "payload_type=#{@object.class} sender=#{@author.diaspora_handle}"
return true return true
end end

View file

@ -44,7 +44,8 @@ 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)
logger.info "user:#{@user.id} successfully received #{@object.class} from person #{@sender.guid}: #{@object.inspect}" logger.info "user:#{@user.id} successfully received #{@object.class} from person #{@sender.guid}: " \
"#{@object.inspect}"
obj obj
end end

View file

@ -4,6 +4,7 @@
module Salmon module Salmon
class EncryptedSlap < Slap class EncryptedSlap < Slap
include Diaspora::Logging
# Construct an encrypted header # Construct an encrypted header
# @return [String] Header XML # @return [String] Header XML
@ -28,13 +29,13 @@ HEADER
# @return [String, Boolean] False if RSAError; XML if no error # @return [String, Boolean] False if RSAError; XML if no error
def xml_for(person) def xml_for(person)
begin begin
super super
rescue OpenSSL::PKey::RSAError => e rescue OpenSSL::PKey::RSAError => e
Rails.logger.info("event => :invalid_rsa_key, :identifier => #{person.diaspora_handle}") logger.error "event=invalid_rsa_key identifier=#{person.diaspora_handle}"
false false
end end
end end
# Takes in a doc of the header and sets the author id # Takes in a doc of the header and sets the author id
# returns an empty hash # returns an empty hash
# @return [Hash] # @return [Hash]
@ -43,7 +44,7 @@ HEADER
self.aes_key = doc.search('aes_key').text self.aes_key = doc.search('aes_key').text
self.iv = doc.search('iv').text self.iv = doc.search('iv').text
end end
# Decrypts an encrypted magic sig envelope # Decrypts an encrypted magic sig envelope
# @param key_hash [Hash] Contains 'key' (aes) and 'iv' values # @param key_hash [Hash] Contains 'key' (aes) and 'iv' values
# @param user [User] # @param user [User]

View file

@ -1,4 +1,6 @@
class WebfingerProfile class WebfingerProfile
include Diaspora::Logging
attr_accessor :webfinger_profile, :account, :links, :hcard, :guid, :public_key, :seed_location attr_accessor :webfinger_profile, :account, :links, :hcard, :guid, :public_key, :seed_location
def initialize(account, webfinger_profile) def initialize(account, webfinger_profile)
@ -20,7 +22,7 @@ class WebfingerProfile
doc.remove_namespaces! doc.remove_namespaces!
account_string = doc.css('Subject').text.gsub('acct:', '').strip account_string = doc.css('Subject').text.gsub('acct:', '').strip
raise "account in profile(#{account_string}) and account requested (#{@account}) do not match" if account_string != @account raise "account in profile(#{account_string}) and account requested (#{@account}) do not match" if account_string != @account
doc.css('Link').each do |l| doc.css('Link').each do |l|
@ -41,7 +43,7 @@ class WebfingerProfile
pubkey = text_of_attribute( doc.at('Link[rel=diaspora-public-key]'), 'href') pubkey = text_of_attribute( doc.at('Link[rel=diaspora-public-key]'), 'href')
@public_key = Base64.decode64 pubkey @public_key = Base64.decode64 pubkey
rescue => e rescue => e
Rails.logger.info("event => :invalid_profile, :identifier => #{@account}") logger.warn "event=invalid_profile identifier=#{@account}"
end end
end end