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 +6 -0
- data/Rakefile +1 -1
- data/lib/logworm_client/logger.rb +11 -8
- data/lib/logworm_client/rack.rb +5 -2
- data/lib/logworm_client/rails.rb +5 -2
- data/lib/logworm_utils/compute.rb +1 -1
- data/lib/logworm_utils/tail.rb +2 -2
- data/logworm_client.gemspec +2 -2
- metadata +4 -4
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
@@ -5,7 +5,7 @@ module Logworm
|
|
5
5
|
|
6
6
|
class Logger
|
7
7
|
# Initialize
|
8
|
-
LW_SERVER = DB.
|
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
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
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
|
data/lib/logworm_client/rack.rb
CHANGED
@@ -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
|
-
|
29
|
-
|
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
|
data/lib/logworm_client/rails.rb
CHANGED
@@ -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
|
-
|
51
|
-
|
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.
|
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
|
data/lib/logworm_utils/tail.rb
CHANGED
@@ -4,7 +4,7 @@ class LogwormTail
|
|
4
4
|
@options = options
|
5
5
|
|
6
6
|
begin
|
7
|
-
@db = Logworm::DB.
|
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.
|
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:"
|
data/logworm_client.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{logworm_client}
|
5
|
-
s.version = "0.
|
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-
|
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
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
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-
|
17
|
+
date: 2010-03-31 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|