Improved overall performance by using logger.debug { ... } instead of logger.debug(...). This decreases the LDAP import dry runtime by ~33%.

This commit is contained in:
Thorsten Eckel 2018-03-20 18:47:49 +01:00
parent 307ce2f506
commit bf6192113a
41 changed files with 148 additions and 148 deletions

View file

@ -47,7 +47,7 @@ module ApplicationController::Authenticates
# already logged in, early exit
if session.id && session[:user_id]
logger.debug 'session based auth check'
logger.debug { 'session based auth check' }
user = User.lookup(id: session[:user_id])
return authentication_check_prerequesits(user, 'session', auth_param) if user
end
@ -64,7 +64,7 @@ module ApplicationController::Authenticates
# check http basic based authentication
authenticate_with_http_basic do |username, password|
request.session_options[:skip] = true # do not send a session cookie
logger.debug "http basic auth check '#{username}'"
logger.debug { "http basic auth check '#{username}'" }
if Setting.get('api_password_access') == false
raise Exceptions::NotAuthorized, 'API password access disabled!'
end
@ -74,7 +74,7 @@ module ApplicationController::Authenticates
# check http token based authentication
authenticate_with_http_token do |token_string, _options|
logger.debug "http token auth check '#{token_string}'"
logger.debug { "http token auth check '#{token_string}'" }
request.session_options[:skip] = true # do not send a session cookie
if Setting.get('api_token_access') == false
raise Exceptions::NotAuthorized, 'API token access disabled!'
@ -114,7 +114,7 @@ module ApplicationController::Authenticates
token = Doorkeeper::OAuth::Token.from_bearer_authorization(request)
if token
request.session_options[:skip] = true # do not send a session cookie
logger.debug "oauth2 token auth check '#{token}'"
logger.debug { "oauth2 token auth check '#{token}'" }
access_token = Doorkeeper::AccessToken.by_token(token)
if !access_token
@ -153,7 +153,7 @@ module ApplicationController::Authenticates
current_user_set(user, auth_type)
user_device_log(user, auth_type)
logger.debug "#{auth_type} for '#{user.login}'"
logger.debug { "#{auth_type} for '#{user.login}'" }
true
end
end

View file

@ -77,7 +77,7 @@ class LongPollingController < ApplicationController
count = count - 1
queue = Sessions.queue(client_id)
if queue && queue[0]
logger.debug "send #{queue.inspect} to #{client_id}"
logger.debug { "send #{queue.inspect} to #{client_id}" }
render json: queue
return
end

View file

@ -136,7 +136,7 @@ stream all accounts
last_channels = []
loop do
logger.debug 'stream controll loop'
logger.debug { 'stream controll loop' }
current_channels = []
channels = Channel.where('active = ? AND area LIKE ?', true, '%::Account')

View file

@ -16,12 +16,12 @@ class Channel::Driver::Facebook
@sync = options['sync']
@pages = options['pages']
Rails.logger.debug 'facebook fetch started'
Rails.logger.debug { 'facebook fetch started' }
fetch_feed
disconnect
Rails.logger.debug 'facebook fetch completed'
Rails.logger.debug { 'facebook fetch completed' }
notice = ''
{
result: 'ok',
@ -104,7 +104,7 @@ returns
# ignore older messages
if (@channel.created_at - 15.days) > Time.zone.parse(post['created_time']) || older_import >= older_import_max
older_import += 1
Rails.logger.debug "post to old: #{post['id']}/#{post['created_time']}"
Rails.logger.debug { "post to old: #{post['id']}/#{post['created_time']}" }
next
end

View file

@ -53,7 +53,7 @@ returns
@sync = options[:sync]
@channel = channel
Rails.logger.debug 'twitter fetch started'
Rails.logger.debug { 'twitter fetch started' }
fetch_mentions
fetch_search
@ -61,7 +61,7 @@ returns
disconnect
Rails.logger.debug 'twitter fetch completed'
Rails.logger.debug { 'twitter fetch completed' }
{
result: 'ok',
@ -317,7 +317,7 @@ returns
next if search[:term] == '#'
next if search[:group_id].blank?
result_type = search[:type] || 'mixed'
Rails.logger.debug " - searching for '#{search[:term]}'"
Rails.logger.debug { " - searching for '#{search[:term]}'" }
older_import = 0
older_import_max = 20
@rest_client.client.search(search[:term], result_type: result_type).collect do |tweet|
@ -326,7 +326,7 @@ returns
# ignore older messages
if (@channel.created_at - 15.days) > tweet.created_at.dup.utc || older_import >= older_import_max
older_import += 1
Rails.logger.debug "tweet to old: #{tweet.id}/#{tweet.created_at}"
Rails.logger.debug { "tweet to old: #{tweet.id}/#{tweet.created_at}" }
next
end
@ -341,7 +341,7 @@ returns
def fetch_mentions
return if @sync[:mentions].blank?
return if @sync[:mentions][:group_id].blank?
Rails.logger.debug ' - searching for mentions'
Rails.logger.debug { ' - searching for mentions' }
older_import = 0
older_import_max = 20
@rest_client.client.mentions_timeline.each do |tweet|
@ -350,7 +350,7 @@ returns
# ignore older messages
if (@channel.created_at - 15.days) > tweet.created_at.dup.utc || older_import >= older_import_max
older_import += 1
Rails.logger.debug "tweet to old: #{tweet.id}/#{tweet.created_at}"
Rails.logger.debug { "tweet to old: #{tweet.id}/#{tweet.created_at}" }
next
end
next if Ticket::Article.find_by(message_id: tweet.id)
@ -362,7 +362,7 @@ returns
def fetch_direct_messages
return if @sync[:direct_messages].blank?
return if @sync[:direct_messages][:group_id].blank?
Rails.logger.debug ' - searching for direct_messages'
Rails.logger.debug { ' - searching for direct_messages' }
older_import = 0
older_import_max = 20
@rest_client.client.direct_messages(full_text: 'true').each do |tweet|
@ -370,7 +370,7 @@ returns
# ignore older messages
if (@channel.created_at - 15.days) > tweet.created_at.dup.utc || older_import >= older_import_max
older_import += 1
Rails.logger.debug "tweet to old: #{tweet.id}/#{tweet.created_at}"
Rails.logger.debug { "tweet to old: #{tweet.id}/#{tweet.created_at}" }
next
end
next if Ticket::Article.find_by(message_id: tweet.id)
@ -398,19 +398,19 @@ returns
sleep 4
12.times do |loop_count|
if Ticket::Article.find_by(message_id: tweet.id)
Rails.logger.debug "Own tweet already imported, skipping tweet #{tweet.id}"
Rails.logger.debug { "Own tweet already imported, skipping tweet #{tweet.id}" }
return true
end
count = Delayed::Job.where('created_at < ?', event_time).count
break if count.zero?
sleep_time = 2 * count
sleep_time = 5 if sleep_time > 5
Rails.logger.debug "Delay importing own tweets - sleep #{sleep_time} (loop #{loop_count})"
Rails.logger.debug { "Delay importing own tweets - sleep #{sleep_time} (loop #{loop_count})" }
sleep sleep_time
end
if Ticket::Article.find_by(message_id: tweet.id)
Rails.logger.debug "Own tweet already imported, skipping tweet #{tweet.id}"
Rails.logger.debug { "Own tweet already imported, skipping tweet #{tweet.id}" }
return true
end
false

View file

@ -349,7 +349,7 @@ class Channel::EmailParser
filename = $1
end
rescue
Rails.logger.debug 'Unable to get filename'
Rails.logger.debug { 'Unable to get filename' }
end
end
@ -532,7 +532,7 @@ returns
filters[setting.name] = Kernel.const_get(Setting.get(setting.name))
end
filters.each do |key, backend|
Rails.logger.debug "run postmaster pre filter #{key}: #{backend}"
Rails.logger.debug { "run postmaster pre filter #{key}: #{backend}" }
begin
backend.run(channel, mail)
rescue => e
@ -684,7 +684,7 @@ returns
filters[setting.name] = Kernel.const_get(Setting.get(setting.name))
end
filters.each_value do |backend|
Rails.logger.debug "run postmaster post filter #{backend}"
Rails.logger.debug { "run postmaster post filter #{backend}" }
begin
backend.run(channel, mail, ticket, article, session_user)
rescue => e

View file

@ -20,7 +20,7 @@ module Channel::Filter::BounceFollowUpCheck
article = Ticket::Article.where(message_id_md5: message_id_md5).order('created_at DESC, id DESC').limit(1).first
next if !article
Rails.logger.debug "Follow up for '##{article.ticket.number}' in bounce email."
Rails.logger.debug { "Follow up for '##{article.ticket.number}' in bounce email." }
mail[ 'x-zammad-ticket-id'.to_sym ] = article.ticket_id
mail[ 'x-zammad-is-auto-response'.to_sym ] = true

View file

@ -9,7 +9,7 @@ module Channel::Filter::FollowUpCheck
# get ticket# from subject
ticket = Ticket::Number.check(mail[:subject])
if ticket
Rails.logger.debug "Follow up for '##{ticket.number}' in subject."
Rails.logger.debug { "Follow up for '##{ticket.number}' in subject." }
mail['x-zammad-ticket-id'.to_sym] = ticket.id
return true
end
@ -20,7 +20,7 @@ module Channel::Filter::FollowUpCheck
if setting.include?('body')
ticket = Ticket::Number.check(mail[:body])
if ticket
Rails.logger.debug "Follow up for '##{ticket.number}' in body."
Rails.logger.debug { "Follow up for '##{ticket.number}' in body." }
mail['x-zammad-ticket-id'.to_sym] = ticket.id
return true
end
@ -32,7 +32,7 @@ module Channel::Filter::FollowUpCheck
next if !attachment[:data]
ticket = Ticket::Number.check(attachment[:data])
next if !ticket
Rails.logger.debug "Follow up for '##{ticket.number}' in attachment."
Rails.logger.debug { "Follow up for '##{ticket.number}' in attachment." }
mail['x-zammad-ticket-id'.to_sym] = ticket.id
return true
end
@ -58,7 +58,7 @@ module Channel::Filter::FollowUpCheck
message_id_md5 = Digest::MD5.hexdigest(message_id)
article = Ticket::Article.where(message_id_md5: message_id_md5).order('created_at DESC, id DESC').limit(1).first
next if !article
Rails.logger.debug "Follow up for '##{article.ticket.number}' in references."
Rails.logger.debug { "Follow up for '##{article.ticket.number}' in references." }
mail['x-zammad-ticket-id'.to_sym] = article.ticket_id
return true
end
@ -97,7 +97,7 @@ module Channel::Filter::FollowUpCheck
# if subject is different, it's no followup
next if subject_to_check != article_first.subject
Rails.logger.debug "Follow up for '##{article.ticket.number}' in references with same subject as inital article."
Rails.logger.debug { "Follow up for '##{article.ticket.number}' in references with same subject as inital article." }
mail['x-zammad-ticket-id'.to_sym] = article_first.ticket_id
return true
end

View file

@ -9,9 +9,9 @@ module Channel::Filter::IdentifySender
if customer_user_id.present?
customer_user = User.lookup(id: customer_user_id)
if customer_user
Rails.logger.debug "Took customer form x-zammad-ticket-customer_id header '#{customer_user_id}'."
Rails.logger.debug { "Took customer form x-zammad-ticket-customer_id header '#{customer_user_id}'." }
else
Rails.logger.debug "Invalid x-zammad-ticket-customer_id header '#{customer_user_id}', no such user - take user from 'from'-header."
Rails.logger.debug { "Invalid x-zammad-ticket-customer_id header '#{customer_user_id}', no such user - take user from 'from'-header." }
end
end
@ -70,9 +70,9 @@ module Channel::Filter::IdentifySender
if session_user_id.present?
session_user = User.lookup(id: session_user_id)
if session_user
Rails.logger.debug "Took session form x-zammad-session-user-id header '#{session_user_id}'."
Rails.logger.debug { "Took session form x-zammad-session-user-id header '#{session_user_id}'." }
else
Rails.logger.debug "Invalid x-zammad-session-user-id header '#{session_user_id}', no such user - take user from 'from'-header."
Rails.logger.debug { "Invalid x-zammad-session-user-id header '#{session_user_id}', no such user - take user from 'from'-header." }
end
end
if !session_user

View file

@ -29,7 +29,7 @@ class OwnModel < ApplicationModel
# return if we run import mode
return if Setting.get('import_mode')
logger.debug "#{self.class.name}.find(#{id}) notify created " + created_at.to_s
logger.debug { "#{self.class.name}.find(#{id}) notify created #{created_at}" }
class_name = self.class.name
class_name.gsub!(/::/, '')
PushMessages.send(
@ -61,7 +61,7 @@ class OwnModel < ApplicationModel
# return if we run import mode
return if Setting.get('import_mode')
logger.debug "#{self.class.name}.find(#{id}) notify UPDATED " + updated_at.to_s
logger.debug { "#{self.class.name}.find(#{id}) notify UPDATED #{updated_at}" }
class_name = self.class.name
class_name.gsub!(/::/, '')
PushMessages.send(
@ -93,7 +93,7 @@ class OwnModel < ApplicationModel
# return if we run import mode
return if Setting.get('import_mode')
logger.debug "#{self.class.name}.find(#{id}) notify TOUCH " + updated_at.to_s
logger.debug { "#{self.class.name}.find(#{id}) notify TOUCH #{updated_at}" }
class_name = self.class.name
class_name.gsub!(/::/, '')
PushMessages.send(
@ -124,7 +124,7 @@ class OwnModel < ApplicationModel
# return if we run import mode
return if Setting.get('import_mode')
logger.debug "#{self.class.name}.find(#{id}) notify DESTOY " + updated_at.to_s
logger.debug { "#{self.class.name}.find(#{id}) notify DESTOY #{updated_at}" }
class_name = self.class.name
class_name.gsub!(/::/, '')
PushMessages.send(

View file

@ -47,7 +47,7 @@ job.run(true)
=end
def run(force = false, start_at = Time.zone.now)
logger.debug "Execute job #{inspect}"
logger.debug { "Execute job #{inspect}" }
if !executable?(start_at) && force == false
if next_run_at && next_run_at <= Time.zone.now
@ -72,7 +72,7 @@ job.run(true)
# find tickets to change
ticket_count, tickets = Ticket.selectors(condition, 2_000)
logger.debug "Job #{name} with #{ticket_count} tickets"
logger.debug { "Job #{name} with #{ticket_count} tickets" }
self.processed = ticket_count || 0
self.running = true

View file

@ -44,7 +44,7 @@ class Observer::Ticket::Article::CommunicateTelegram::BackgroundJob
return
end
Rails.logger.debug "result info: #{result}"
Rails.logger.debug { "result info: #{result}" }
# only private, group messages. channel messages do not have from key
if result['from'] && result['chat']

View file

@ -54,7 +54,7 @@ class Observer::Transaction < ActiveRecord::Observer
end
def self.execute_singel_backend(backend, item, params)
Rails.logger.debug "Execute singel backend #{backend}"
Rails.logger.debug { "Execute singel backend #{backend}" }
begin
UserInfo.current_user_id = nil
integration = backend.new(item, params)

View file

@ -105,7 +105,7 @@ note: will not take down package migrations, use Package.unlink instead
if package == false
raise "Can't link package, '#{package_base_dir}' is no package source directory!"
end
logger.debug package.inspect
logger.debug { package.inspect }
package
end
@ -424,7 +424,7 @@ execute all pending package migrations at once
if File.exist?(location)
content_fs = _read_file(file)
if content_fs == data
logger.debug "NOTICE: file '#{location}' already exists, skip install"
logger.debug { "NOTICE: file '#{location}' already exists, skip install" }
return true
end
backup_location = location + '.save'

View file

@ -153,7 +153,7 @@ returns
private
def validate_permissions
Rails.logger.debug "self permission: #{self.permission_ids}"
Rails.logger.debug { "self permission: #{self.permission_ids}" }
return true if !self.permission_ids
permission_ids.each do |permission_id|
permission = Permission.lookup(id: permission_id)

View file

@ -301,7 +301,7 @@ class Scheduler < ApplicationModel
result = nil
realtime = Benchmark.realtime do
logger.debug "*** worker thread, #{Delayed::Job.all.count} in queue"
logger.debug { "*** worker thread, #{Delayed::Job.all.count} in queue" }
result = Delayed::Worker.new.work_off
end
@ -309,7 +309,7 @@ class Scheduler < ApplicationModel
if count.zero?
sleep wait
logger.debug '*** worker thread loop'
logger.debug { '*** worker thread loop' }
else
format "*** #{count} jobs processed at %.4f j/s, %d failed ...\n", count / realtime, result.last
end

View file

@ -137,7 +137,7 @@ reload config settings
def reset_change_id
@@current[name] = state_current[:value]
change_id = rand(999_999_999).to_s
logger.debug "Setting.reset_change_id: set new cache, #{change_id}"
logger.debug { "Setting.reset_change_id: set new cache, #{change_id}" }
Cache.write('Setting::ChangeId', change_id, { expires_in: 24.hours })
@@lookup_at = nil # rubocop:disable Style/ClassVars
true

View file

@ -8,7 +8,7 @@ class Store::Provider::File
location = get_location(sha)
permission = '600'
if !File.exist?(location)
Rails.logger.debug "storge write '#{location}' (#{permission})"
Rails.logger.debug { "storge write '#{location}' (#{permission})" }
file = File.new(location, 'wb')
file.write(data)
file.close
@ -27,7 +27,7 @@ class Store::Provider::File
# read file from fs
def self.get(sha)
location = get_location(sha)
Rails.logger.debug "read from fs #{location}"
Rails.logger.debug { "read from fs #{location}" }
if !File.exist?(location)
raise "ERROR: No such file #{location}"
end

View file

@ -805,7 +805,7 @@ perform changes on ticket
=end
def perform_changes(perform, perform_origin, item = nil, current_user_id = nil)
logger.debug "Perform #{perform_origin} #{perform.inspect} on Ticket.find(#{id})"
logger.debug { "Perform #{perform_origin} #{perform.inspect} on Ticket.find(#{id})" }
# if the configuration contains the deletion of the ticket then
# we skip all other ticket changes because they does not matter
@ -1065,7 +1065,7 @@ perform changes on ticket
changed = true
self[attribute] = value['value']
logger.debug "set #{object_name}.#{attribute} = #{value['value'].inspect}"
logger.debug { "set #{object_name}.#{attribute} = #{value['value'].inspect}" }
end
return if !changed
save

View file

@ -153,7 +153,7 @@ class Transaction::Notification
created_by_id: created_by_id,
user_id: user.id,
)
Rails.logger.debug "sent ticket online notifiaction to agent (#{@item[:type]}/#{ticket.id}/#{user.email})"
Rails.logger.debug { "sent ticket online notifiaction to agent (#{@item[:type]}/#{ticket.id}/#{user.email})" }
end
# ignore email channel notificaiton and empty emails
@ -207,7 +207,7 @@ class Transaction::Notification
main_object: ticket,
attachments: attachments,
)
Rails.logger.debug "sent ticket email notifiaction to agent (#{@item[:type]}/#{ticket.id}/#{user.email})"
Rails.logger.debug { "sent ticket email notifiaction to agent (#{@item[:type]}/#{ticket.id}/#{user.email})" }
end
end

View file

@ -116,7 +116,7 @@ class Transaction::Slack
if sent_value
value = Cache.get(cache_key)
if value == sent_value
Rails.logger.debug "did not send webhook, already sent (#{@item[:type]}/#{ticket.id}/#{local_config['webhook']})"
Rails.logger.debug { "did not send webhook, already sent (#{@item[:type]}/#{ticket.id}/#{local_config['webhook']})" }
next
end
Cache.write(
@ -159,7 +159,7 @@ class Transaction::Slack
logo_url = local_config['logo_url']
end
Rails.logger.debug "sent webhook (#{@item[:type]}/#{ticket.id}/#{local_config['webhook']})"
Rails.logger.debug { "sent webhook (#{@item[:type]}/#{ticket.id}/#{local_config['webhook']})" }
notifier = Slack::Notifier.new(
local_config['webhook'],
@ -188,7 +188,7 @@ class Transaction::Slack
Rails.logger.error "Unable to post webhook: #{local_config['webhook']}: #{result.inspect}"
next
end
Rails.logger.debug "sent webhook (#{@item[:type]}/#{ticket.id}/#{local_config['webhook']})"
Rails.logger.debug { "sent webhook (#{@item[:type]}/#{ticket.id}/#{local_config['webhook']})" }
end
end

View file

@ -198,7 +198,7 @@ send user notification about new device or new location for device
def notification_send(template)
user = User.find(user_id)
Rails.logger.debug "Send notification (#{template}) to: #{user.email}"
Rails.logger.debug { "Send notification (#{template}) to: #{user.email}" }
NotificationFactory::Mailer.notification(
template: template,

View file

@ -5,7 +5,7 @@ class ResetSettingsPlugin < Delayed::Plugin
callbacks do |lifecycle|
lifecycle.before(:invoke_job) do |*_args|
Rails.logger.debug 'Resetting Settings before Job execution'
Rails.logger.debug { 'Resetting Settings before Job execution' }
# reload all settings before starting a job
# otherwise it might be that changed settings

View file

@ -445,7 +445,7 @@ class String
end
rescue
# regexp was not possible because of some string encoding issue, use next
Rails.logger.debug "Invalid string/charset combination with regexp #{regexp} in string"
Rails.logger.debug { "Invalid string/charset combination with regexp #{regexp} in string" }
end
end

View file

@ -79,15 +79,15 @@ returns on fail
end
# probe inbound
Rails.logger.debug "INBOUND PROBE PROVIDER: #{settings[:inbound].inspect}"
Rails.logger.debug { "INBOUND PROBE PROVIDER: #{settings[:inbound].inspect}" }
result_inbound = EmailHelper::Probe.inbound(settings[:inbound])
Rails.logger.debug "INBOUND RESULT PROVIDER: #{result_inbound.inspect}"
Rails.logger.debug { "INBOUND RESULT PROVIDER: #{result_inbound.inspect}" }
next if result_inbound[:result] != 'ok'
# probe outbound
Rails.logger.debug "OUTBOUND PROBE PROVIDER: #{settings[:outbound].inspect}"
Rails.logger.debug { "OUTBOUND PROBE PROVIDER: #{settings[:outbound].inspect}" }
result_outbound = EmailHelper::Probe.outbound(settings[:outbound], params[:email])
Rails.logger.debug "OUTBOUND RESULT PROVIDER: #{result_outbound.inspect}"
Rails.logger.debug { "OUTBOUND RESULT PROVIDER: #{result_outbound.inspect}" }
next if result_outbound[:result] != 'ok'
return {
@ -116,9 +116,9 @@ returns on fail
config[:options][:folder] = params[:folder]
end
Rails.logger.debug "INBOUND PROBE GUESS: #{config.inspect}"
Rails.logger.debug { "INBOUND PROBE GUESS: #{config.inspect}" }
result_inbound = EmailHelper::Probe.inbound(config)
Rails.logger.debug "INBOUND RESULT GUESS: #{result_inbound.inspect}"
Rails.logger.debug { "INBOUND RESULT GUESS: #{result_inbound.inspect}" }
next if result_inbound[:result] != 'ok'
@ -144,9 +144,9 @@ returns on fail
success = false
outbound_map.each do |config|
Rails.logger.debug "OUTBOUND PROBE GUESS: #{config.inspect}"
Rails.logger.debug { "OUTBOUND PROBE GUESS: #{config.inspect}" }
result_outbound = EmailHelper::Probe.outbound(config, params[:email])
Rails.logger.debug "OUTBOUND RESULT GUESS: #{result_outbound.inspect}"
Rails.logger.debug { "OUTBOUND RESULT GUESS: #{result_outbound.inspect}" }
next if result_outbound[:result] != 'ok'

View file

@ -121,8 +121,8 @@ result
end
def to_user(item)
Rails.logger.debug 'Create user from item...'
Rails.logger.debug item.inspect
Rails.logger.debug { 'Create user from item...' }
Rails.logger.debug { item.inspect }
# do item_user lookup
item_user = user(item)
@ -196,9 +196,9 @@ result
def to_ticket(post, group_id, channel, page)
Rails.logger.debug 'Create ticket from post...'
Rails.logger.debug post.inspect
Rails.logger.debug group_id.inspect
Rails.logger.debug { 'Create ticket from post...' }
Rails.logger.debug { post.inspect }
Rails.logger.debug { group_id.inspect }
user = to_user(post)
return if !user
@ -228,9 +228,9 @@ result
def to_article(post, ticket, page)
Rails.logger.debug 'Create article from post...'
Rails.logger.debug post.inspect
Rails.logger.debug ticket.inspect
Rails.logger.debug { 'Create article from post...' }
Rails.logger.debug { post.inspect }
Rails.logger.debug { ticket.inspect }
user = to_user(post)
return if !user
@ -309,7 +309,7 @@ result
end
def to_group(post, group_id, channel, page)
Rails.logger.debug 'import post'
Rails.logger.debug { 'import post' }
return if !post['message']
ticket = nil
@ -332,9 +332,9 @@ result
if article[:type] != 'facebook feed comment'
raise "Can't handle unknown facebook article type '#{article[:type]}'."
end
Rails.logger.debug 'Create feed comment from article...'
Rails.logger.debug { 'Create feed comment from article...' }
post = @client.put_comment(article[:in_reply_to], article[:body])
Rails.logger.debug post.inspect
Rails.logger.debug { post.inspect }
@client.get_object(post['id'])
end
@ -371,8 +371,8 @@ result
def nested_comments(comments, in_reply_to)
Rails.logger.debug 'Fetching nested comments...'
Rails.logger.debug comments.inspect
Rails.logger.debug { 'Fetching nested comments...' }
Rails.logger.debug { comments.inspect }
result = []
return result if comments.blank?

View file

@ -134,7 +134,7 @@ returns
if !references[model_class.to_s][item]
references[model_class.to_s][item] = 0
end
Rails.logger.debug "FOUND (by id) #{model_class}->#{item} #{count}!"
Rails.logger.debug { "FOUND (by id) #{model_class}->#{item} #{count}!" }
references[model_class.to_s][item] += count
end
end
@ -154,7 +154,7 @@ returns
if !references[model_class.to_s][col_name]
references[model_class.to_s][col_name] = 0
end
Rails.logger.debug "FOUND (by ref without class) #{model_class}->#{col_name} #{count}!"
Rails.logger.debug { "FOUND (by ref without class) #{model_class}->#{col_name} #{count}!" }
references[model_class.to_s][col_name] += count
end
@ -166,7 +166,7 @@ returns
if !references[model_class.to_s][col_name]
references[model_class.to_s][col_name] = 0
end
Rails.logger.debug "FOUND (by ref with class) #{model_class}->#{col_name} #{count}!"
Rails.logger.debug { "FOUND (by ref with class) #{model_class}->#{col_name} #{count}!" }
references[model_class.to_s][col_name] += count
end
end
@ -233,7 +233,7 @@ returns
# collect items and attributes to update
items_to_update = {}
attributes.each_key do |attribute|
Rails.logger.debug "#{object_name}: #{model}.#{attribute}->#{object_id_to_merge}->#{object_id_primary}"
Rails.logger.debug { "#{object_name}: #{model}.#{attribute}->#{object_id_to_merge}->#{object_id_primary}" }
model_object.where("#{attribute} = ?", object_id_to_merge).each do |item|
if !items_to_update[item.id]
items_to_update[item.id] = item

View file

@ -94,7 +94,7 @@ update processors
)
end
Rails.logger.info "# curl -X PUT \"#{url}\" \\"
Rails.logger.debug "-d '#{data.to_json}'"
Rails.logger.debug { "-d '#{data.to_json}'" }
item.delete(:action)
response = UserAgent.put(
url,
@ -163,7 +163,7 @@ create/update/delete index
end
Rails.logger.info "# curl -X PUT \"#{url}\" \\"
Rails.logger.debug "-d '#{data[:data].to_json}'"
Rails.logger.debug { "-d '#{data[:data].to_json}'" }
response = UserAgent.put(
url,
@ -201,7 +201,7 @@ add new object to search index
return if url.blank?
Rails.logger.info "# curl -X POST \"#{url}\" \\"
Rails.logger.debug "-d '#{data.to_json}'"
Rails.logger.debug { "-d '#{data.to_json}'" }
response = UserAgent.post(
url,
@ -350,7 +350,7 @@ return search result
data['query']['bool']['must'].push condition
Rails.logger.info "# curl -X POST \"#{url}\" \\"
Rails.logger.debug " -d'#{data.to_json}'"
Rails.logger.debug { " -d'#{data.to_json}'" }
response = UserAgent.get(
url,
@ -448,7 +448,7 @@ get count of tickets and tickets which match on selector
data = selector2query(selectors, current_user, aggs_interval, limit)
Rails.logger.info "# curl -X POST \"#{url}\" \\"
Rails.logger.debug " -d'#{data.to_json}'"
Rails.logger.debug { " -d'#{data.to_json}'" }
response = UserAgent.get(
url,
@ -471,7 +471,7 @@ get count of tickets and tickets which match on selector
response: response,
)
end
Rails.logger.debug response.data.to_json
Rails.logger.debug { response.data.to_json }
if aggs_interval.blank? || aggs_interval[:interval].blank?
ticket_ids = []

View file

@ -69,7 +69,7 @@ class Sequencer
end
state.to_h.tap do |result|
logger.debug("Returning Sequence '#{sequence.name}' result: #{result.inspect}")
logger.debug { "Returning Sequence '#{sequence.name}' result: #{result.inspect}" }
end
end

View file

@ -88,7 +88,7 @@ class Sequencer
# @return [Object, nil]
def optional(attribute)
return get(attribute) if @attributes.known?(attribute)
logger.debug("Access to unknown optional attribute '#{attribute}'.")
logger.debug { "Access to unknown optional attribute '#{attribute}'." }
nil
end
@ -184,13 +184,13 @@ class Sequencer
end
def set(attribute, value)
logger.debug("Setting '#{attribute}' value (#{value.class.name}): #{value.inspect}")
logger.debug { "Setting '#{attribute}' value (#{value.class.name}): #{value.inspect}" }
@values[attribute] = value
end
def get(attribute)
value = @values[attribute]
logger.debug("Getting '#{attribute}' value (#{value.class.name}): #{value.inspect}")
logger.debug { "Getting '#{attribute}' value (#{value.class.name}): #{value.inspect}" }
value
end
@ -209,19 +209,19 @@ class Sequencer
def initialize_attributes(units)
log_start_finish(:debug, 'Attributes lifespan initialization') do
@attributes = Sequencer::Units::Attributes.new(units.declarations)
logger.debug("Attributes lifespan: #{@attributes.inspect}")
logger.debug { "Attributes lifespan: #{@attributes.inspect}" }
end
end
def initialize_parameters(parameters)
logger.debug("Initializing Sequencer::State with initial parameters: #{parameters.inspect}")
logger.debug { "Initializing Sequencer::State with initial parameters: #{parameters.inspect}" }
log_start_finish(:debug, 'Attribute value provisioning check and initialization') do
@attributes.each do |identifier, attribute|
if !attribute.will_be_used?
logger.debug("Attribute '#{identifier}' is provided by Unit(s) but never used.")
logger.debug { "Attribute '#{identifier}' is provided by Unit(s) but never used." }
next
end
@ -250,7 +250,7 @@ class Sequencer
def initialize_expectations(expected_attributes)
expected_attributes.each do |identifier|
logger.debug("Adding attribute '#{identifier}' to the list of expected result attributes.")
logger.debug { "Adding attribute '#{identifier}' to the list of expected result attributes." }
@attributes[identifier].to = @result_index
end
end
@ -262,7 +262,7 @@ class Sequencer
remove = !attribute.will_be_used?
remove ||= attribute.to <= @index
if remove && attribute.will_be_used?
logger.debug("Removing unneeded attribute '#{identifier}': #{@values[identifier].inspect}")
logger.debug { "Removing unneeded attribute '#{identifier}': #{@values[identifier].inspect}" }
end
remove
end

View file

@ -29,7 +29,7 @@ class Sequencer
private
def changed?
logger.debug("Changed instance associations: #{changes.inspect}")
logger.debug { "Changed instance associations: #{changes.inspect}" }
changes.present?
end

View file

@ -13,17 +13,17 @@ class Sequencer
state.provide(:associations) do
associations.collect do |association|
logger.debug("Checking association '#{association}'")
logger.debug { "Checking association '#{association}'" }
next if !mapped.key?(association)
# remove from the mapped values if it's an association
value = mapped.delete(association)
logger.debug("Extracted association '#{association}' value '#{value.inspect}'")
logger.debug { "Extracted association '#{association}' value '#{value.inspect}'" }
# skip if we don't track them
next if tracked_associations.exclude?(association)
logger.debug("Using value of association '#{association}'")
logger.debug { "Using value of association '#{association}'" }
[association, value]
end.compact.to_h
end

View file

@ -22,9 +22,9 @@ class Sequencer
end
def skip_action?(action)
logger.debug("Checking if skip is necessary for action #{action.inspect}.")
logger.debug { "Checking if skip is necessary for action #{action.inspect}." }
return false if action.blank?
logger.debug("Checking if skip is necessary for skip_actions #{skip_actions.inspect}.")
logger.debug { "Checking if skip is necessary for skip_actions #{skip_actions.inspect}." }
return false if skip_actions.blank?
return true if skip_actions.include?(action)
return true if skip_actions.include?(:any)
@ -39,9 +39,9 @@ class Sequencer
def process
action = state.optional(:action)
if self.class.skip_action?(action)
logger.debug("Skipping due to provided action #{action.inspect}.")
logger.debug { "Skipping due to provided action #{action.inspect}." }
else
logger.debug("Nope. Won't skip action #{action.inspect}.")
logger.debug { "Nope. Won't skip action #{action.inspect}." }
super
end
end

View file

@ -17,7 +17,7 @@ class Sequencer
def process
return if !skip?
logger.debug("Skipping. Blank #{attribute} found: #{attribute_value.inspect}")
logger.debug { "Skipping. Blank #{attribute} found: #{attribute_value.inspect}" }
state.provide(:action, :skipped)
end

View file

@ -17,7 +17,7 @@ class Sequencer
def process
return if !skip?
logger.debug("Skipping. Missing mandatory attributes for #{attribute}: #{attribute_value.inspect}")
logger.debug { "Skipping. Missing mandatory attributes for #{attribute}: #{attribute_value.inspect}" }
state.provide(:action, :skipped)
end

View file

@ -35,7 +35,7 @@ class Sequencer
private
def changed?
logger.debug("Changed instance attributes: #{changes.inspect}")
logger.debug { "Changed instance attributes: #{changes.inspect}" }
changes.present?
end

View file

@ -39,7 +39,7 @@ class Sequencer
}
}
logger.debug "Fetching and processing #{per_page} items (page: #{page}, offset: #{offset}) from Exchange folder '#{display_path}' (total: #{total})"
logger.debug { "Fetching and processing #{per_page} items (page: #{page}, offset: #{offset}) from Exchange folder '#{display_path}' (total: #{total})" }
folder.items(opts).each do |item|
@ -47,7 +47,7 @@ class Sequencer
item = parameters[:resource]
logger.debug "Extracting attributes from Exchange item: #{item.get_all_properties!.inspect}"
logger.debug { "Extracting attributes from Exchange item: #{item.get_all_properties!.inspect}" }
parameters.merge(
resource: ::Import::Exchange::ItemAttributes.extract(item),

View file

@ -713,7 +713,7 @@ returns
def self.log(level, message)
if defined?(Rails)
if level == 'debug'
Rails.logger.debug message
Rails.logger.debug { message }
elsif level == 'notice'
Rails.logger.notice message
else

View file

@ -75,6 +75,6 @@ class Sessions::Client
end
def log(msg)
Rails.logger.debug "client(#{@node_id}.#{@client_id}) #{msg}"
Rails.logger.debug { "client(#{@node_id}.#{@client_id}) #{msg}" }
end
end

View file

@ -226,8 +226,8 @@ returns
end
def to_user(params)
Rails.logger.debug 'Create user from message...'
Rails.logger.debug params.inspect
Rails.logger.debug { 'Create user from message...' }
Rails.logger.debug { params.inspect }
# do message_user lookup
message_user = user(params)
@ -272,10 +272,10 @@ returns
def to_ticket(params, user, group_id, channel)
UserInfo.current_user_id = user.id
Rails.logger.debug 'Create ticket from message...'
Rails.logger.debug params.inspect
Rails.logger.debug user.inspect
Rails.logger.debug group_id.inspect
Rails.logger.debug { 'Create ticket from message...' }
Rails.logger.debug { params.inspect }
Rails.logger.debug { user.inspect }
Rails.logger.debug { group_id.inspect }
# prepare title
title = '-'
@ -341,13 +341,13 @@ returns
def to_article(params, user, ticket, channel, article = nil)
if article
Rails.logger.debug 'Update article from message...'
Rails.logger.debug { 'Update article from message...' }
else
Rails.logger.debug 'Create article from message...'
Rails.logger.debug { 'Create article from message...' }
end
Rails.logger.debug params.inspect
Rails.logger.debug user.inspect
Rails.logger.debug ticket.inspect
Rails.logger.debug { params.inspect }
Rails.logger.debug { user.inspect }
Rails.logger.debug { ticket.inspect }
UserInfo.current_user_id = user.id
@ -529,7 +529,7 @@ returns
def to_group(params, group_id, channel)
# begin import
Rails.logger.debug 'import message'
Rails.logger.debug { 'import message' }
# map channel_post params to message
if params[:channel_post]
@ -660,12 +660,12 @@ returns
def from_article(article)
message = nil
Rails.logger.debug "Create telegram personal message from article to '#{article[:to]}'..."
Rails.logger.debug { "Create telegram personal message from article to '#{article[:to]}'..." }
message = {}
# TODO: create telegram message here
Rails.logger.debug message.inspect
Rails.logger.debug { message.inspect }
message
end

View file

@ -10,12 +10,12 @@ class TweetBase
def user(tweet)
if tweet.class == Twitter::DirectMessage
Rails.logger.debug "Twitter sender for dm (#{tweet.id}): found"
Rails.logger.debug tweet.sender.inspect
Rails.logger.debug { "Twitter sender for dm (#{tweet.id}): found" }
Rails.logger.debug { tweet.sender.inspect }
tweet.sender
elsif tweet.class == Twitter::Tweet
Rails.logger.debug "Twitter sender for tweet (#{tweet.id}): found"
Rails.logger.debug tweet.user.inspect
Rails.logger.debug { "Twitter sender for tweet (#{tweet.id}): found" }
Rails.logger.debug { tweet.user.inspect }
tweet.user
else
raise "Unknown tweet type '#{tweet.class}'"
@ -25,8 +25,8 @@ class TweetBase
def to_user(tweet)
Rails.logger.debug 'Create user from tweet...'
Rails.logger.debug tweet.inspect
Rails.logger.debug { 'Create user from tweet...' }
Rails.logger.debug { tweet.inspect }
# do tweet_user lookup
tweet_user = user(tweet)
@ -102,10 +102,10 @@ class TweetBase
def to_ticket(tweet, user, group_id, channel)
UserInfo.current_user_id = user.id
Rails.logger.debug 'Create ticket from tweet...'
Rails.logger.debug tweet.inspect
Rails.logger.debug user.inspect
Rails.logger.debug group_id.inspect
Rails.logger.debug { 'Create ticket from tweet...' }
Rails.logger.debug { tweet.inspect }
Rails.logger.debug { user.inspect }
Rails.logger.debug { group_id.inspect }
if tweet.class == Twitter::DirectMessage
ticket = Ticket.find_by(
@ -143,10 +143,10 @@ class TweetBase
def to_article(tweet, user, ticket, channel)
Rails.logger.debug 'Create article from tweet...'
Rails.logger.debug tweet.inspect
Rails.logger.debug user.inspect
Rails.logger.debug ticket.inspect
Rails.logger.debug { 'Create article from tweet...' }
Rails.logger.debug { tweet.inspect }
Rails.logger.debug { user.inspect }
Rails.logger.debug { ticket.inspect }
# import tweet
to = nil
@ -233,7 +233,7 @@ class TweetBase
def to_group(tweet, group_id, channel)
Rails.logger.debug 'import tweet'
Rails.logger.debug { 'import tweet' }
# use transaction
if @connection_type == 'stream'
@ -289,7 +289,7 @@ class TweetBase
tweet = nil
if article[:type] == 'twitter direct-message'
Rails.logger.debug "Create twitter direct message from article to '#{article[:to]}'..."
Rails.logger.debug { "Create twitter direct message from article to '#{article[:to]}'..." }
tweet = @client.create_direct_message(
article[:to],
@ -298,7 +298,7 @@ class TweetBase
)
elsif article[:type] == 'twitter status'
Rails.logger.debug 'Create tweet from article...'
Rails.logger.debug { 'Create tweet from article...' }
tweet = @client.update(
article[:body],
@ -310,7 +310,7 @@ class TweetBase
raise "Can't handle unknown twitter article type '#{article[:type]}'."
end
Rails.logger.debug tweet.inspect
Rails.logger.debug { tweet.inspect }
tweet
end
@ -392,7 +392,7 @@ class TweetBase
next if !local_channel.options[:user]
next if !local_channel.options[:user][:id]
next if local_channel.options[:user][:id].to_s != tweet_user.id.to_s
Rails.logger.debug "Tweet is sent by local account with user id #{tweet_user.id} and tweet.id #{tweet.id}"
Rails.logger.debug { "Tweet is sent by local account with user id #{tweet_user.id} and tweet.id #{tweet.id}" }
return true
end
false