Improved logging.
This commit is contained in:
parent
9ce362cabe
commit
5df60dd057
7 changed files with 20 additions and 21 deletions
|
@ -29,7 +29,7 @@ class Sessions::Backend::ActivityStream
|
|||
end
|
||||
|
||||
def client_key
|
||||
"as::load::#{ self.class.to_s }::#{ @user.id }::#{ @client_id }"
|
||||
"as::load::#{ self.class }::#{ @user.id }::#{ @client_id }"
|
||||
end
|
||||
|
||||
def push
|
||||
|
@ -53,7 +53,7 @@ class Sessions::Backend::ActivityStream
|
|||
}
|
||||
end
|
||||
|
||||
@client.log 'notify', "push activity_stream #{ data.first.class.to_s } for user #{ @user.id }"
|
||||
@client.log "push activity_stream #{ data.first.class } for user #{ @user.id }"
|
||||
@client.send(
|
||||
event: 'activity_stream_rebuild',
|
||||
collection: 'activity_stream',
|
||||
|
|
|
@ -73,13 +73,13 @@ class Sessions::Backend::Collections::Base
|
|||
assets: assets,
|
||||
}
|
||||
end
|
||||
@client.log 'notify', "push assets for push_collection #{ items.first.class.to_s } for user #{ @user.id }"
|
||||
@client.log "push assets for push_collection #{ items.first.class.to_s } for user #{ @user.id }"
|
||||
@client.send(
|
||||
data: assets,
|
||||
event: [ 'loadAssets' ],
|
||||
)
|
||||
|
||||
@client.log 'notify', "push push_collection #{ items.first.class.to_s } for user #{ @user.id }"
|
||||
@client.log "push push_collection #{ items.first.class.to_s } for user #{ @user.id }"
|
||||
@client.send(
|
||||
event: 'resetCollection',
|
||||
data: {
|
||||
|
|
|
@ -53,7 +53,7 @@ class Sessions::Backend::Rss
|
|||
}
|
||||
end
|
||||
|
||||
@client.log 'notify', "push rss for user #{@user.id}"
|
||||
@client.log "push rss for user #{@user.id}"
|
||||
@client.send(
|
||||
event: 'rss_rebuild',
|
||||
collection: 'dashboard_rss',
|
||||
|
|
|
@ -58,7 +58,7 @@ class Sessions::Backend::TicketCreate
|
|||
}
|
||||
end
|
||||
|
||||
@client.log 'notify', "push ticket_create for user #{ @user.id }"
|
||||
@client.log "push ticket_create for user #{ @user.id }"
|
||||
@client.send(
|
||||
collection: 'ticket_create_attributes',
|
||||
data: data,
|
||||
|
|
|
@ -56,7 +56,7 @@ class Sessions::Backend::TicketOverviewIndex
|
|||
}
|
||||
end
|
||||
|
||||
@client.log 'notify', "push overview_index for user #{ @user.id }"
|
||||
@client.log "push overview_index for user #{ @user.id }"
|
||||
@client.send(
|
||||
event: ['ticket_overview_index'],
|
||||
data: data,
|
||||
|
|
|
@ -24,13 +24,13 @@ class Sessions::Backend::TicketOverviewList
|
|||
data = { list: overview_data, index: overview }
|
||||
result.push data
|
||||
}
|
||||
puts "LOG A #{result.inspect}"
|
||||
Rails.logger.debug "LOG A #{result.inspect}"
|
||||
# no data exists
|
||||
return if !result || result.empty?
|
||||
|
||||
# no change exists
|
||||
return if @last_change == result
|
||||
puts "LOG B #{result.inspect}"
|
||||
Rails.logger.debug "LOG B #{result.inspect}"
|
||||
|
||||
# remember last state
|
||||
@last_change = result
|
||||
|
@ -45,22 +45,22 @@ class Sessions::Backend::TicketOverviewList
|
|||
def push
|
||||
|
||||
# check interval
|
||||
puts "LOG 1 #{@user.inspect}"
|
||||
Rails.logger.debug "LOG 1 #{@user.inspect}"
|
||||
return if Sessions::CacheIn.get( self.client_key )
|
||||
|
||||
# reset check interval
|
||||
puts "LOG 2 #{@ttl.seconds}"
|
||||
Rails.logger.debug "LOG 2 #{@ttl.seconds}"
|
||||
Sessions::CacheIn.set( self.client_key, true, { expires_in: @ttl.seconds } )
|
||||
|
||||
# check if min one ticket has changed
|
||||
last_ticket_change = Ticket.latest_change
|
||||
puts "LOG 3 #{last_ticket_change}/#{@last_ticket_change}"
|
||||
Rails.logger.debug "LOG 3 #{last_ticket_change}/#{@last_ticket_change}"
|
||||
return if last_ticket_change == @last_ticket_change
|
||||
@last_ticket_change = last_ticket_change
|
||||
|
||||
# load current data
|
||||
items = self.load
|
||||
puts "LOG 4 #{items.inspect}"
|
||||
Rails.logger.debug "LOG 4 #{items.inspect}"
|
||||
return if !items
|
||||
|
||||
# push overviews
|
||||
|
@ -107,7 +107,7 @@ class Sessions::Backend::TicketOverviewList
|
|||
results.push result
|
||||
else
|
||||
|
||||
@client.log 'notify', "push overview_list for user #{ @user.id }"
|
||||
@client.log "push overview_list for user #{ @user.id }"
|
||||
|
||||
# send update to browser
|
||||
@client.send(
|
||||
|
|
|
@ -2,9 +2,9 @@ class Sessions::Client
|
|||
|
||||
def initialize( client_id )
|
||||
@client_id = client_id
|
||||
self.log 'notify', '---client start ws connection---'
|
||||
self.log '---client start ws connection---'
|
||||
self.fetch
|
||||
self.log 'notify', '---client exiting ws connection---'
|
||||
self.log '---client exiting ws connection---'
|
||||
end
|
||||
|
||||
def fetch
|
||||
|
@ -49,14 +49,14 @@ class Sessions::Client
|
|||
end
|
||||
|
||||
loop_count += 1
|
||||
self.log 'notice', "---client - looking for data of user #{user.id}"
|
||||
self.log "---client - looking for data of user #{user.id}"
|
||||
|
||||
# push messages from backends
|
||||
backend_pool.each {|pool|
|
||||
pool.push
|
||||
}
|
||||
|
||||
self.log 'notice', '---/client-'
|
||||
self.log '---/client-'
|
||||
|
||||
# start faster in the beginnig
|
||||
if loop_count < 20
|
||||
|
@ -72,8 +72,7 @@ class Sessions::Client
|
|||
Sessions.send( @client_id, data )
|
||||
end
|
||||
|
||||
def log( level, data )
|
||||
return if level == 'notice'
|
||||
puts "#{Time.now}:client(#{ @client_id }) #{ data }"
|
||||
def log( msg )
|
||||
Rails.logger.info "client(#{ @client_id }) #{ msg }"
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue