Improved logging.

This commit is contained in:
Martin Edenhofer 2015-05-05 10:26:53 +02:00
parent cf3e6274d0
commit 89b19caa1d
4 changed files with 9 additions and 9 deletions

View file

@ -41,7 +41,7 @@ class String
return if ActiveRecord::Base.connection_config[:adapter] != 'mysql2'
self.each_char.select {|c|
if c.bytes.count > 3
puts "WARNING: strip out 4 bytes utf8 chars '#{c}' of '#{ self }'"
Rails.logger.warn "strip out 4 bytes utf8 chars '#{c}' of '#{ self }'"
next
end
c

View file

@ -37,7 +37,7 @@ class GeoIp::ZammadGeoIp
Cache.write( cache_key, data, { expires_in: 90.days } )
rescue => e
puts "ERROR: #{host}#{url}: " + e.inspect
Rails.logger.error "#{host}#{url}: #{e.inspect}"
Cache.write( cache_key, data, { expires_in: 60.minutes } )
end
data

View file

@ -57,7 +57,7 @@ create/update/delete index
password: Setting.get('es_password'),
}
)
puts "# #{response.code.to_s}"
Rails.logger.info "# #{response.code}"
return true if response.success?
raise response.inspect
end
@ -108,7 +108,7 @@ remove whole data from index
url = build_url( type, o_id )
return if !url
puts "# curl -X DELETE \"#{url}\""
Rails.logger.info "# curl -X DELETE \"#{url}\""
response = UserAgent.delete(
url,
@ -210,7 +210,7 @@ return search result
Rails.logger.info "# #{response.code.to_s}"
if !response.success?
puts "ERROR: #{response.inspect}"
Rails.logger.error "ERROR: #{response.inspect}"
return []
end
data = response.data
@ -220,7 +220,7 @@ return search result
return ids if !data['hits']
return ids if !data['hits']['hits']
data['hits']['hits'].each { |item|
puts "... #{item['_type'].to_s} #{item['_id'].to_s}"
Rails.logger.info "... #{item['_type'].to_s} #{item['_id'].to_s}"
data = {
id: item['_id'],
type: item['_type'],

View file

@ -24,9 +24,9 @@ put working hours matrix and timezone in function, returns UTC working hours mat
begin
time_diff = Time.parse(start_time.to_s).in_time_zone(timezone).utc_offset
rescue Exception => e
puts "ERROR: Can't fine tomezone #{timezone}"
puts e.inspect
puts e.backtrace
Rails.logger.error "Can't fine tomezone #{timezone}"
Rails.logger.error e.inspect
Rails.logger.error e.backtrace
end
end
beginning_of_workday = Time.parse("1977-10-27 #{config['beginning_of_workday']}")