From 89b19caa1d2adba9930a21fe053dadc6a98a000e Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 5 May 2015 10:26:53 +0200 Subject: [PATCH] Improved logging. --- lib/core_ext/string.rb | 2 +- lib/geo_ip/zammad_geo_ip.rb | 2 +- lib/search_index_backend.rb | 8 ++++---- lib/time_calculation.rb | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/core_ext/string.rb b/lib/core_ext/string.rb index 817d9f9ac..13e0077b6 100644 --- a/lib/core_ext/string.rb +++ b/lib/core_ext/string.rb @@ -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 diff --git a/lib/geo_ip/zammad_geo_ip.rb b/lib/geo_ip/zammad_geo_ip.rb index 130fc6522..9259ae35e 100644 --- a/lib/geo_ip/zammad_geo_ip.rb +++ b/lib/geo_ip/zammad_geo_ip.rb @@ -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 diff --git a/lib/search_index_backend.rb b/lib/search_index_backend.rb index 83f7bc43c..8a66d3f32 100644 --- a/lib/search_index_backend.rb +++ b/lib/search_index_backend.rb @@ -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'], diff --git a/lib/time_calculation.rb b/lib/time_calculation.rb index 46f031cd0..e8666860e 100644 --- a/lib/time_calculation.rb +++ b/lib/time_calculation.rb @@ -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']}")