logworm_amqp 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +5 -0
- data/Manifest +0 -1
- data/Rakefile +1 -1
- data/lib/client/logger.rb +31 -5
- data/lib/logworm_amqp.rb +6 -0
- data/logworm_amqp.gemspec +2 -2
- metadata +4 -4
data/CHANGELOG
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
v0.9.2
|
2
|
+
Adds support for attaching extra data to log entries (via log_with_request). The main purpose is to allow users to add their own
|
3
|
+
data to the automatically-generated web_log log.
|
4
|
+
Renames (or, rather, aliases for now) lw_log to log_in
|
5
|
+
|
1
6
|
v0.9.1
|
2
7
|
Explicitly state dependency on minion 0.1.15
|
3
8
|
v0.9.0
|
data/Manifest
CHANGED
data/Rakefile
CHANGED
data/lib/client/logger.rb
CHANGED
@@ -5,6 +5,7 @@ module Logworm
|
|
5
5
|
|
6
6
|
class Logger
|
7
7
|
$lr_queue = []
|
8
|
+
$attaches = {}
|
8
9
|
|
9
10
|
###
|
10
11
|
# Use connection to the backend servers specified in environment variable or config file
|
@@ -46,11 +47,7 @@ module Logworm
|
|
46
47
|
return unless values.is_a? Hash
|
47
48
|
|
48
49
|
# Turn keys into symbols, delete empty ones, rename conflicting ones
|
49
|
-
kvalues = values
|
50
|
-
kvalues = Hash[*kvalues.flatten]
|
51
|
-
[:_ts, :_ts_utc, :_request_id].each do |k|
|
52
|
-
kvalues["orig_#{k}".to_sym] = kvalues[k] if kvalues.has_key? k
|
53
|
-
end
|
50
|
+
kvalues = cleanup(values)
|
54
51
|
|
55
52
|
# Add information
|
56
53
|
ts = Time.now.utc
|
@@ -61,6 +58,18 @@ module Logworm
|
|
61
58
|
# Enqueue
|
62
59
|
$lr_queue << [table, kvalues]
|
63
60
|
end
|
61
|
+
|
62
|
+
###
|
63
|
+
# Allows to add fields to ALL log entries that go to a particular table.
|
64
|
+
# Can be used, for example, to add user-level and app-specific data to the :web_log log
|
65
|
+
# Notice that it overwrites previously attached fields. For example
|
66
|
+
# attach_to_log(:xx, {:a = 1})
|
67
|
+
# attach_to_log(:xx, {:a = 2})
|
68
|
+
# will end up attaching just :a => 2 to every :xx log
|
69
|
+
###
|
70
|
+
def self.attach_to_log(table, values = {})
|
71
|
+
$attaches[table] = ($attaches[table] ? $attaches[table].merge(values) : values)
|
72
|
+
end
|
64
73
|
|
65
74
|
###
|
66
75
|
# Sends the entries to the server, if configured
|
@@ -82,6 +91,12 @@ module Logworm
|
|
82
91
|
return [0,0]
|
83
92
|
end
|
84
93
|
|
94
|
+
# Apply a-posteriori attachments
|
95
|
+
# It merges, and so that attachment may overwrite
|
96
|
+
$lr_queue.each do |le|
|
97
|
+
le[1].merge!($attaches[le[0]]) if $attaches[le[0]]
|
98
|
+
end
|
99
|
+
|
85
100
|
startTime = Time.now
|
86
101
|
$lw_server.batch_log($lr_queue.to_json)
|
87
102
|
$lr_queue = []
|
@@ -89,5 +104,16 @@ module Logworm
|
|
89
104
|
|
90
105
|
[to_send, (endTime - startTime)]
|
91
106
|
end
|
107
|
+
|
108
|
+
private
|
109
|
+
# Turn keys into symbols, delete empty ones, rename conflicting ones
|
110
|
+
def self.cleanup(values)
|
111
|
+
kvalues = {}
|
112
|
+
values.each {|k,v| kvalues[k.to_sym] = v unless k.to_s == ""}
|
113
|
+
[:_ts, :_ts_utc, :_request_id].each do |k|
|
114
|
+
kvalues["orig_#{k}".to_sym] = kvalues[k] if kvalues.has_key? k
|
115
|
+
end
|
116
|
+
kvalues
|
117
|
+
end
|
92
118
|
end
|
93
119
|
end
|
data/lib/logworm_amqp.rb
CHANGED
@@ -9,6 +9,12 @@ require File.dirname(__FILE__) + '/client/rails'
|
|
9
9
|
def lw_log (logname, values)
|
10
10
|
Logworm::Logger.log(logname, values)
|
11
11
|
end
|
12
|
+
alias :log_in :lw_log
|
13
|
+
|
14
|
+
def lw_with_log(values)
|
15
|
+
Logworm::Logger.attach_to_log(:web_log, values)
|
16
|
+
end
|
17
|
+
alias :log_with_request :lw_with_log
|
12
18
|
|
13
19
|
###
|
14
20
|
# Perform a query against the logworm server
|
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.
|
5
|
+
s.version = "0.9.2"
|
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-
|
9
|
+
s.date = %q{2010-08-11}
|
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:
|
4
|
+
hash: 63
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
version: 0.9.
|
9
|
+
- 2
|
10
|
+
version: 0.9.2
|
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
|
+
date: 2010-08-11 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|