logworm_amqp 0.9.4 → 0.9.5

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,4 +1,12 @@
1
- v.9.4
1
+ v0.9.5
2
+ A few changes:
3
+ - Add support for log_environments(arr) configuration, to specify a list of environments in which logworm should log
4
+ (thanks to Erik Hanson @ Top Prospect)
5
+ - Fixed problems with request.path and request.status on Rails 2.3.x
6
+ (thanks to Andrew Cove @ getaquirk.com)
7
+ - The db server now specifies a PREFIX for AMQP queue names, to make debugging easier (e.g., to send msgs to lw-staging)
8
+
9
+ v0.9.4
2
10
  Minor timeout changes to production environment
3
11
 
4
12
  v0.9.3
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'echoe'
2
- Echoe.new('logworm_amqp', '0.9.4') do |p|
2
+ Echoe.new('logworm_amqp', '0.9.5') do |p|
3
3
  p.description = "logworm - logging service"
4
4
  p.url = "http://www.logworm.com"
5
5
  p.author = "Pomelo, LLC"
data/lib/base/db.rb CHANGED
@@ -115,6 +115,7 @@ module Logworm
115
115
  resp = db_call(:get, "#{host_with_protocol}/amqp_url")
116
116
  @amqp_url = resp["url"]
117
117
  @stats_freq = resp["stats_freq"]
118
+ @amqp_prefix = resp["prefix"] || "lw"
118
119
  $stderr.puts "logworm server acquired: #{@amqp_url.gsub(/[^@]+@/, "amqp://")}"
119
120
  Minion.amqp_url = @amqp_url
120
121
  reset_stats
@@ -130,7 +131,7 @@ module Logworm
130
131
  if get_amqp_url
131
132
  content = payload.to_json
132
133
  sig= signature(content, @token_secret )
133
- Minion.enqueue(queue, {:payload => content, :consumer_key => @token, :signature => sig,
134
+ Minion.enqueue("#{@amqp_prefix}.#{queue}", {:payload => content, :consumer_key => @token, :signature => sig,
134
135
  :env => ENV['RACK_ENV'] || "?"})
135
136
  end
136
137
  end
@@ -152,7 +153,7 @@ module Logworm
152
153
  def push_stats()
153
154
  avg = sprintf('%.6f', (@total_time / @tock)).to_f
154
155
  len = sprintf('%.2f', (Time.now - @sampling_start)).to_f
155
- to_amqp("lw.stats", {:avg => avg , :max => @amqp_max, :min => @amqp_min,
156
+ to_amqp("stats", {:avg => avg , :max => @amqp_max, :min => @amqp_min,
156
157
  :total => @total_time, :count => @tock, :sampling_length => len})
157
158
  $stderr.puts "logworm statistics: #{@tock} messages sent in last #{len} secs. Times: #{avg * 1000}/#{@amqp_min * 1000}/#{@amqp_max * 1000} (avg/min/max msecs)"
158
159
  reset_stats
@@ -166,7 +167,7 @@ module Logworm
166
167
 
167
168
  def batch_log(entries)
168
169
  recording_stats do
169
- to_amqp("lw.logging", {:entries => entries})
170
+ to_amqp("logging", {:entries => entries})
170
171
  end
171
172
  end
172
173
 
data/lib/client/rack.rb CHANGED
@@ -8,13 +8,14 @@ module Logworm
8
8
 
9
9
  @log_requests = (options[:donot_log_requests].nil? or options[:donot_log_requests] != true)
10
10
  @log_headers = (options[:log_headers] and options[:log_headers] == true)
11
- @dev_logging = (options[:log_in_development] and options[:log_in_development] == true)
11
+ @log_envs = options[:log_environments] || ["production"]
12
+ @log_envs << "development" if (options[:log_in_development] and options[:log_in_development] == true) # backwards compatibility
12
13
  Logger.use_default_db
13
14
  @timeout = (ENV['RACK_ENV'] == 'production' ? 1 : 5)
14
15
  end
15
16
 
16
17
  def call(env)
17
- return @app.call(env) unless (ENV['RACK_ENV'] == 'production' or (ENV['RACK_ENV'] == 'development' and @dev_logging))
18
+ return @app.call(env) unless @log_envs.include?(ENV['RACK_ENV'])
18
19
 
19
20
  Logger.start_cycle
20
21
  begin
@@ -30,7 +31,7 @@ module Logworm
30
31
  private
31
32
  def log_request(env, status, response_headers, appTime)
32
33
  method = env['REQUEST_METHOD']
33
- path = (env['REQUEST_PATH'].nil? or env['REQUEST_PATH'] == "") ? "/" : env['REQUEST_PATH']
34
+ path = env['PATH_INFO'] || env['REQUEST_PATH'] || "/"
34
35
  ip = env['REMOTE_ADDR']
35
36
  http_headers = env.reject {|k,v| !(k.to_s =~ /^HTTP/) }
36
37
  queue_size = env['HTTP_X_HEROKU_QUEUE_DEPTH'].nil? ? -1 : env['HTTP_X_HEROKU_QUEUE_DEPTH'].to_i
data/lib/client/rails.rb CHANGED
@@ -7,13 +7,13 @@
7
7
  if defined?(ActionController) and Rails::VERSION::STRING and Rails::VERSION::STRING < "3.0.0"
8
8
 
9
9
  require 'benchmark'
10
-
10
+
11
11
  ActionController::Base.class_eval do
12
12
  ## Basic settings: log requests, without headers. Use default db, and timeout after 1 second
13
13
  @@log_requests = true
14
14
  @@log_headers = false
15
- @@dev_logging = false
16
- @@timeout = (RAILS_ENV == 'production' ? 1 : 5)
15
+ @@log_envs = ["production"]
16
+ @@timeout = (RAILS_ENV == 'production' ? 1 : 5)
17
17
  Logworm::Logger.use_default_db
18
18
 
19
19
  ###
@@ -35,8 +35,12 @@ if defined?(ActionController) and Rails::VERSION::STRING and Rails::VERSION::STR
35
35
  ###
36
36
  # Turn on logging in development mode
37
37
  ###
38
- def self.log_in_development
39
- @@dev_logging = true
38
+ def self.log_in_development # Kept for backwards compatibility
39
+ @@log_envs << "development"
40
+ end
41
+
42
+ def self.log_environments(*envs)
43
+ @@log_envs = envs
40
44
  end
41
45
 
42
46
  ###
@@ -44,9 +48,7 @@ if defined?(ActionController) and Rails::VERSION::STRING and Rails::VERSION::STR
44
48
  # Call the original method, logs the request unless disabled, and flushes the logworm list
45
49
  ###
46
50
  def process_with_logworm_log(request, response, method = :perform_action, *arguments)
47
- unless (RAILS_ENV == 'production' or (RAILS_ENV == 'development' and @@dev_logging))
48
- return process_without_logworm_log(request, response, method, *arguments)
49
- end
51
+ return process_without_logworm_log(request, response, method, *arguments) unless @@log_envs.include?(RAILS_ENV)
50
52
 
51
53
  Logworm::Logger.start_cycle
52
54
  begin
@@ -64,10 +66,10 @@ if defined?(ActionController) and Rails::VERSION::STRING and Rails::VERSION::STR
64
66
  private
65
67
  def log_request(request, response, appTime)
66
68
  method = request.env['REQUEST_METHOD']
67
- path = request.env['REQUEST_PATH'].blank? ? "/" : request.env['REQUEST_PATH']
69
+ path = request.path.blank? ? "/" : request.path
68
70
  ip = request.env['REMOTE_ADDR']
69
71
  http_headers = request.headers.reject {|k,v| !(k.to_s =~ /^HTTP/) }
70
- status = response.status[0..2]
72
+ status = response.status ? (response.status.is_a?(String) ? response.status[0..2].to_i : response.status.to_s.to_i) : -1
71
73
  queue_size = request.env['HTTP_X_HEROKU_QUEUE_DEPTH'].blank? ? -1 : request.env['HTTP_X_HEROKU_QUEUE_DEPTH'].to_i
72
74
 
73
75
  entry = { :summary => "#{method} #{path} - #{status} #{appTime}",
data/logworm_amqp.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{logworm_amqp}
5
- s.version = "0.9.4"
5
+ s.version = "0.9.5"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Pomelo, LLC"]
9
- s.date = %q{2010-08-18}
9
+ s.date = %q{2010-08-19}
10
10
  s.description = %q{logworm - logging service}
11
11
  s.email = %q{schapira@pomelollc.com}
12
12
  s.executables = ["lw-compute", "lw-tail"]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logworm_amqp
3
3
  version: !ruby/object:Gem::Version
4
- hash: 51
4
+ hash: 49
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 4
10
- version: 0.9.4
9
+ - 5
10
+ version: 0.9.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Pomelo, LLC
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-18 00:00:00 -04:00
18
+ date: 2010-08-19 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency