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