logworm_client 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ v0.5.0
2
+ Supports new base logworm gem, which can work as a Heroku addon
3
+ Configuration parameters now stored as URL
4
+ No error if logworm cannot be properly configured -- lw_log simply ignored
5
+ No logging in development mode
6
+
1
7
  v0.4.1
2
8
  Show in console time spent communicating with the server.
3
9
 
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'echoe'
2
- Echoe.new('logworm_client', '0.4.1') do |p|
2
+ Echoe.new('logworm_client', '0.5.0') do |p|
3
3
  p.description = "logworm client utilities"
4
4
  p.url = "http://www.logworm.com"
5
5
  p.author = "Pomelo, LLC"
@@ -5,7 +5,7 @@ module Logworm
5
5
 
6
6
  class Logger
7
7
  # Initialize
8
- LW_SERVER = DB.new() # Find from config file, or from keys
8
+ LW_SERVER = DB.from_config
9
9
  $lr_queue = []
10
10
 
11
11
  def self.start_cycle
@@ -33,14 +33,17 @@ module Logworm
33
33
  end
34
34
 
35
35
  def self.flush
36
- if $lr_queue.size > 0
37
- begin
38
- LW_SERVER.batch_log($lr_queue.to_json)
39
- rescue Exception => e
40
- $stderr.puts "in Logworm::Logger.flush: #{e}"
41
- end
42
- $lr_queue = []
36
+ to_send = $lr_queue.size
37
+ return 0 if to_send == 0
38
+ $stderr.puts "Logworm not configured. #{$to_send} entries dropped." and return 0 unless LW_SERVER
39
+
40
+ begin
41
+ LW_SERVER.batch_log($lr_queue.to_json)
42
+ rescue Exception => e
43
+ $stderr.puts "in Logworm::Logger.flush: #{e}"
43
44
  end
45
+ $lr_queue = []
46
+ to_send
44
47
  end
45
48
  end
46
49
  end
@@ -10,6 +10,8 @@ module Logworm
10
10
  end
11
11
 
12
12
  def call(env)
13
+ return @app.call(env) unless env['RACK_ENV'] == 'production'
14
+
13
15
  startTime = Time.now
14
16
  Logger.start_cycle
15
17
  status, headers, body = @app.call(env)
@@ -25,8 +27,9 @@ module Logworm
25
27
  :profiling => appTime}) if @log_requests_short
26
28
  begin
27
29
  Timeout::timeout(1) {
28
- ts = Benchmark.realtime {Logger.flush} # Flushes only if there are any entries. Times out after a second
29
- env['rack.errors'].puts("\t *** logworm - logs sent in #{ts} seconds")
30
+ sent = 0
31
+ ts = Benchmark.realtime {sent = Logger.flush} # Flushes only if there are any entries. Times out after a second
32
+ env['rack.errors'].puts("\t *** logworm - logs sent in #{ts} seconds") if sent
30
33
  }
31
34
  rescue Exception => e
32
35
  # Ignore --nothing we can do
@@ -24,6 +24,8 @@ if defined?(ActionController)
24
24
  end
25
25
 
26
26
  def process_with_logworm_log(request, response, method = :perform_action, *arguments)
27
+ return process_without_logworm_log(request, response, method, *arguments) unless RAILS_ENV == 'production'
28
+
27
29
  startTime = Time.now
28
30
  Logworm::Logger.start_cycle
29
31
  begin
@@ -47,8 +49,9 @@ if defined?(ActionController)
47
49
  :profiling => appTime}) if @@log_requests_short
48
50
  begin
49
51
  Timeout::timeout(1) {
50
- ts = Benchmark.realtime {Logworm::Logger.flush} # Flushes only if there are any entries. Times out after a second
51
- logger.info("\t *** logworm - logs sent in #{ts} seconds")
52
+ sent = 0
53
+ ts = Benchmark.realtime {sent = Logworm::Logger.flush} # Flushes only if there are any entries. Times out after a second
54
+ logger.info("\t *** logworm - logs sent in #{ts} seconds") if sent
52
55
  }
53
56
  rescue Exception => e
54
57
  # Ignore --nothing we can do
@@ -8,7 +8,7 @@ class LogwormCompute
8
8
  @valuefield = @field ? "#{@function}(#{@field})" : @function
9
9
 
10
10
  begin
11
- @db = Logworm::DB.new(false)
11
+ @db = Logworm::DB.from_config
12
12
  spec = {:aggregate_function => @function, :aggregate_argument => @field}.merge(@options)
13
13
  @query = Logworm::QueryBuilder.new(spec)
14
14
  rescue Exception => e
@@ -4,7 +4,7 @@ class LogwormTail
4
4
  @options = options
5
5
 
6
6
  begin
7
- @db = Logworm::DB.new(false)
7
+ @db = Logworm::DB.from_config
8
8
  @query = Logworm::QueryBuilder.new(@options.merge(:force_ts => true))
9
9
  rescue Exception => e
10
10
  $stderr.puts "Error: #{e}"
@@ -14,7 +14,7 @@ class LogwormTail
14
14
 
15
15
  def self.list
16
16
  begin
17
- @db = Logworm::DB.new(false)
17
+ @db = Logworm::DB.from_config
18
18
  @tables = @db.tables
19
19
  if @tables and @tables.size > 0
20
20
  puts "The following are the tables that you've created thus far:"
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{logworm_client}
5
- s.version = "0.4.1"
5
+ s.version = "0.5.0"
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-03-13}
9
+ s.date = %q{2010-03-31}
10
10
  s.description = %q{logworm client utilities}
11
11
  s.email = %q{schapira@pomelollc.com}
12
12
  s.executables = ["lw-compute", "lw-heroku", "lw-tail"]
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 4
8
- - 1
9
- version: 0.4.1
7
+ - 5
8
+ - 0
9
+ version: 0.5.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Pomelo, LLC
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-13 00:00:00 -05:00
17
+ date: 2010-03-31 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency