mongo_request_logger 0.2.7 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -1
- data/.travis.yml +2 -0
- data/CHANGELOG.md +6 -1
- data/angular/app/img/flags/ss.png +0 -0
- data/angular/app/partials/logs.html +2 -1
- data/angular/app/partials/page.html +1 -1
- data/config.ru +1 -1
- data/lib/mongo_request_logger/adapters/base.rb +3 -3
- data/lib/mongo_request_logger/adapters/mongo.rb +18 -24
- data/lib/mongo_request_logger/adapters/moped.rb +13 -38
- data/lib/mongo_request_logger/config.rb +90 -34
- data/lib/mongo_request_logger/version.rb +1 -1
- data/spec/config_spec.rb +130 -0
- data/spec/moped_logger_spec.rb +108 -0
- metadata +6 -6
- data/Gemfile.lock +0 -61
- data/gemfiles/sinatra1.3.gemfile.lock +0 -130
- data/gemfiles/sinatra1.4.gemfile.lock +0 -61
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 660d6aa96f97e5ca818a92abef7fc96544ea2cbd
|
4
|
+
data.tar.gz: 6859e94ceb5658485f79340d52c6798cf3e7db70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2173487a90d1d0ab9cd8c6a9f406606fbcf0e3e806706dcd4ade311ea820eee7330d3d9f465b6167728b015aa215ab5eead698deba5d59dc164c7f4f2c681381
|
7
|
+
data.tar.gz: fdef6ac1a55a2a2736addde2c160e316d151122e25948a55e8bdba06d6e39bc56ead26e87435eba2fd2eaa0a271e567ce65dc0860e0c779cdeef0048d1357453
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,10 +1,15 @@
|
|
1
|
+
## 0.3.0
|
2
|
+
|
3
|
+
* Improved config parsing for the Moped driver.
|
4
|
+
* Fixed some minor bugs on web portal.
|
5
|
+
|
1
6
|
## 0.2.7
|
2
7
|
|
3
8
|
* Ensure that the collection is created on the primary node in a replica set, even if the session consistency is set to :eventual.
|
4
9
|
|
5
10
|
## 0.2.6
|
6
11
|
|
7
|
-
* Handle forking with Unicorn and Passenger (Moped driver only).
|
12
|
+
* Handle forking with Unicorn and Passenger (Moped driver only. Requires Moped 1.2.0 + ).
|
8
13
|
|
9
14
|
## 0.2.5
|
10
15
|
|
Binary file
|
@@ -76,7 +76,8 @@
|
|
76
76
|
<tr>
|
77
77
|
<td colspan="10">
|
78
78
|
<ng-switch on="log_footer()">
|
79
|
-
<span ng-switch-when="no_matches">No logs matched your criteria</span>
|
79
|
+
<span ng-switch-when="no_matches && mongo_query">No logs matched your criteria</span>
|
80
|
+
<span ng-switch-when="no_matches && !mongo_query">Searching...</span>
|
80
81
|
<span ng-switch-when="end">End of results</span>
|
81
82
|
<span ng-switch-default>
|
82
83
|
<button class="btn" ng-click="get_more_results()">Show more results</button>
|
@@ -7,7 +7,7 @@
|
|
7
7
|
<tr ui-if="log.exception"><td>Error</td><td>{{ log.exception }}</td></tr>
|
8
8
|
<tr><td>Tags</td><td>{{ tags() }}</td></tr>
|
9
9
|
<tr ui-if="log.args"><td>Args</td><td>{{ log.args }}</td></tr>
|
10
|
-
<tr ui-if="log.params"><td>Params</td><td>{{ log.params }}</td></tr>
|
10
|
+
<tr ui-if="log.data.params"><td>Params</td><td>{{ log.data.params | json }}</td></tr>
|
11
11
|
<tr ng-repeat="line in extra"><td>{{line.key}}</td><td>{{line.value | truncate:150 }}</td></tr>
|
12
12
|
</table>
|
13
13
|
|
data/config.ru
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
require 'moped'
|
3
3
|
require 'mongo_request_logger/viewer'
|
4
4
|
|
5
|
-
config = {database: ENV['DB'] || 'request_logger_test', collection: 'server_log', capsize: 10
|
5
|
+
config = {database: ENV['DB'] || 'request_logger_test', collection: 'server_log', capsize: 10}
|
6
6
|
|
7
7
|
MongoRequestLogger::Viewer.adapter = MongoRequestLogger::Adapters::Moped.new(config)
|
8
8
|
|
@@ -7,7 +7,7 @@ module MongoRequestLogger
|
|
7
7
|
attr_reader :configuration, :connection, :connection_type, :collection, :authenticated
|
8
8
|
|
9
9
|
def collection_name
|
10
|
-
@configuration
|
10
|
+
@configuration.collection
|
11
11
|
end
|
12
12
|
|
13
13
|
def authenticated?
|
@@ -16,8 +16,8 @@ module MongoRequestLogger
|
|
16
16
|
|
17
17
|
def check_for_collection
|
18
18
|
# setup the capped collection if it doesn't already exist
|
19
|
-
create_collection unless @connection.collection_names.include?(
|
20
|
-
@collection = @connection[
|
19
|
+
create_collection unless @connection.collection_names.include?(collection_name)
|
20
|
+
@collection = @connection[collection_name]
|
21
21
|
end
|
22
22
|
|
23
23
|
def reset_collection
|
@@ -1,36 +1,26 @@
|
|
1
1
|
# Adapted from https://github.com/le0pard/mongodb_logger/
|
2
2
|
|
3
3
|
require 'mongo_request_logger/adapters/base'
|
4
|
+
require 'mongo_request_logger/config'
|
4
5
|
|
5
6
|
module MongoRequestLogger
|
6
7
|
module Adapters
|
7
8
|
class Mongo < Base
|
8
9
|
|
9
10
|
def initialize(options = {})
|
10
|
-
|
11
|
-
@configuration = options
|
12
|
-
@configuration['host'] ||= '127.0.0.1'
|
13
|
-
@configuration['port'] ||= '27017'
|
14
|
-
@configuration['collection'] ||= 'server_log'
|
11
|
+
options = MongoRequestLogger::Config.new(options) unless options.is_a? MongoRequestLogger::Config
|
12
|
+
@configuration = options
|
15
13
|
|
14
|
+
mongo_connection_object
|
16
15
|
connect
|
17
16
|
|
18
17
|
check_for_collection
|
19
18
|
end
|
20
19
|
|
21
20
|
def connect
|
22
|
-
|
23
|
-
|
24
|
-
@
|
25
|
-
@connection ||= mongo_connection_object.db(@configuration['database'])
|
26
|
-
@authenticated = true
|
27
|
-
else
|
28
|
-
@connection ||= mongo_connection_object.db(@configuration['database'])
|
29
|
-
if @configuration['username'] && @configuration['password']
|
30
|
-
# the driver stores credentials in case reconnection is required
|
31
|
-
@authenticated = @connection.authenticate(@configuration['username'],
|
32
|
-
@configuration['password'])
|
33
|
-
end
|
21
|
+
@connection ||= mongo_connection_object.db(@configuration.database)
|
22
|
+
if @configuration.credentials
|
23
|
+
@authenticated = @connection.authenticate(*@configuration.credentials)
|
34
24
|
end
|
35
25
|
end
|
36
26
|
|
@@ -75,15 +65,19 @@ module MongoRequestLogger
|
|
75
65
|
private
|
76
66
|
|
77
67
|
def mongo_connection_object
|
78
|
-
|
79
|
-
|
68
|
+
hosts = @configuration.hosts
|
69
|
+
if @configuration['uri']
|
70
|
+
::Mongo::Connection.from_uri(@configuration['uri'])
|
71
|
+
elsif hosts.count > 1
|
72
|
+
conn = ::Mongo::ReplSetConnection.new(*(hosts <<
|
80
73
|
{:connect => true, :pool_timeout => 6}))
|
81
|
-
@configuration['replica_set'] = true
|
82
|
-
elsif @configuration['url']
|
83
|
-
conn = ::Mongo::Connection.from_uri(@configuration['url'])
|
74
|
+
@configuration['replica_set'] = true # is this correct?
|
84
75
|
else
|
85
|
-
|
86
|
-
|
76
|
+
host = @configuration['host'] || '127.0.0.1'
|
77
|
+
port = @configuration['port'] || '27017'
|
78
|
+
|
79
|
+
conn = ::Mongo::Connection.new(host,
|
80
|
+
port,
|
87
81
|
:connect => true,
|
88
82
|
:pool_timeout => 6)
|
89
83
|
end
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'mongo_request_logger/adapters/base'
|
4
4
|
require 'active_support/core_ext/hash/indifferent_access'
|
5
|
+
require 'mongo_request_logger/config'
|
5
6
|
|
6
7
|
module MongoRequestLogger
|
7
8
|
module Adapters
|
@@ -12,32 +13,22 @@ module MongoRequestLogger
|
|
12
13
|
|
13
14
|
|
14
15
|
def initialize(options = {})
|
15
|
-
|
16
|
-
@configuration
|
17
|
-
@
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
@connection.use @configuration['database']
|
25
|
-
@authenticated = true
|
26
|
-
else
|
27
|
-
@connection ||= mongo_connection_object
|
28
|
-
@connection.use @configuration['database']
|
29
|
-
|
30
|
-
login
|
31
|
-
end
|
16
|
+
options = MongoRequestLogger::Config.new(options) unless options.is_a? MongoRequestLogger::Config
|
17
|
+
@configuration = options
|
18
|
+
@connection = ::Moped::Session.new(*options.moped_arguments)
|
19
|
+
|
20
|
+
login
|
21
|
+
|
22
|
+
MongoRequestLogger::Adapters::Moped.connection = @connection
|
23
|
+
|
24
|
+
@connection_type = @connection.class
|
32
25
|
|
33
26
|
check_for_collection
|
34
27
|
end
|
35
28
|
|
36
29
|
def login
|
37
|
-
if @configuration
|
38
|
-
|
39
|
-
@authenticated = @connection.login(@configuration['username'],
|
40
|
-
@configuration['password'])
|
30
|
+
if @configuration.credentials
|
31
|
+
@authenticated = @connection.login(*@configuration.credentials)
|
41
32
|
end
|
42
33
|
|
43
34
|
# Allow MongoDB configured both with and without authentication
|
@@ -51,7 +42,7 @@ module MongoRequestLogger
|
|
51
42
|
|
52
43
|
def create_collection
|
53
44
|
@connection.cluster.with_primary do |node|
|
54
|
-
node.command(@configuration
|
45
|
+
node.command(@configuration.database, {create: collection_name, capped: true, size: @configuration.capsize})
|
55
46
|
end
|
56
47
|
end
|
57
48
|
|
@@ -84,22 +75,6 @@ module MongoRequestLogger
|
|
84
75
|
@collection.drop
|
85
76
|
end
|
86
77
|
|
87
|
-
private
|
88
|
-
|
89
|
-
def mongo_connection_object
|
90
|
-
if @configuration['hosts']
|
91
|
-
conn = ::Moped::Session.new(@configuration['hosts'].map{|(host,port)| "#{host}:#{port}"}, :timeout => 6)
|
92
|
-
@configuration['replica_set'] = true
|
93
|
-
elsif @configuration['url']
|
94
|
-
conn = ::Moped::Session.connect(@configuration['url'])
|
95
|
-
else
|
96
|
-
conn = ::Moped::Session.new(["#{@configuration['host']}:#{@configuration['port']}"], :timeout => 6)
|
97
|
-
end
|
98
|
-
@connection_type = conn.class
|
99
|
-
|
100
|
-
MongoRequestLogger::Adapters::Moped.connection = conn
|
101
|
-
conn
|
102
|
-
end
|
103
78
|
|
104
79
|
end
|
105
80
|
end
|
@@ -1,5 +1,11 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
|
3
|
+
begin
|
4
|
+
require 'moped/mongo_uri'
|
5
|
+
rescue LoadError
|
6
|
+
# Ignore
|
7
|
+
end
|
8
|
+
|
3
9
|
module MongoRequestLogger
|
4
10
|
class Config
|
5
11
|
attr_accessor :raw_config
|
@@ -7,14 +13,13 @@ module MongoRequestLogger
|
|
7
13
|
attr_accessor :namespace
|
8
14
|
|
9
15
|
def initialize(config=nil)
|
10
|
-
@raw_config = {}
|
11
16
|
@params = {}
|
12
17
|
@namespace = nil
|
13
|
-
load_config(config) unless config.nil?
|
18
|
+
load_config(config.stringify_keys) unless config.nil?
|
14
19
|
end
|
15
20
|
|
16
21
|
def namespaced(namespace)
|
17
|
-
config = deep_merge(@
|
22
|
+
config = deep_merge(@params['common'], @params[namespace])
|
18
23
|
ac = self.class.new(config)
|
19
24
|
ac.namespace = namespace
|
20
25
|
ac
|
@@ -22,7 +27,7 @@ module MongoRequestLogger
|
|
22
27
|
|
23
28
|
|
24
29
|
def namespaces
|
25
|
-
@
|
30
|
+
@params.keys - %w(common)
|
26
31
|
end
|
27
32
|
|
28
33
|
def load_file(file)
|
@@ -36,30 +41,21 @@ module MongoRequestLogger
|
|
36
41
|
|
37
42
|
def deep_merge(a, b)
|
38
43
|
if a.is_a? Hash and b.is_a? Hash
|
39
|
-
r = a.
|
44
|
+
r = a.stringify_keys
|
45
|
+
b = b.stringify_keys
|
40
46
|
for k, v in b
|
41
47
|
r[k] = deep_merge(a[k], v)
|
42
48
|
end
|
43
49
|
r
|
44
50
|
elsif b.is_a? Hash
|
45
|
-
b.
|
51
|
+
b.stringify_keys
|
46
52
|
else
|
47
53
|
b
|
48
54
|
end
|
49
55
|
end
|
50
56
|
|
51
57
|
def load_config(config)
|
52
|
-
@
|
53
|
-
@params = {}
|
54
|
-
@raw_config.each { |k, v|
|
55
|
-
if v.is_a? Hash
|
56
|
-
@params[k] = self.class.new(v)
|
57
|
-
else
|
58
|
-
@params[k] = v
|
59
|
-
end
|
60
|
-
}
|
61
|
-
|
62
|
-
create_accessors!
|
58
|
+
@params = deep_merge(@params, config)
|
63
59
|
end
|
64
60
|
|
65
61
|
def has?(param)
|
@@ -82,28 +78,88 @@ module MongoRequestLogger
|
|
82
78
|
self
|
83
79
|
end
|
84
80
|
|
85
|
-
def
|
86
|
-
@params.
|
87
|
-
|
81
|
+
def to_hash
|
82
|
+
@params.symbolize_keys
|
83
|
+
end
|
84
|
+
|
85
|
+
def hosts
|
86
|
+
if self['hosts']
|
87
|
+
return self['hosts']
|
88
|
+
elsif self.moped_uri
|
89
|
+
return self.moped_uri.hosts
|
90
|
+
else
|
91
|
+
host = self['host'] || '127.0.0.1'
|
92
|
+
port = self['port'] || 27017
|
93
|
+
return ["#{host}:#{port}"]
|
88
94
|
end
|
89
95
|
end
|
90
96
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
+
def credentials
|
98
|
+
if moped_uri && moped_uri.auth_provided?
|
99
|
+
[moped_uri.username, moped_uri.password]
|
100
|
+
elsif self['username'] && self['password']
|
101
|
+
[self['username'], self['password']]
|
102
|
+
else
|
103
|
+
nil
|
104
|
+
end
|
105
|
+
end
|
97
106
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
107
|
+
def database
|
108
|
+
if self['database']
|
109
|
+
self['database']
|
110
|
+
elsif moped_uri
|
111
|
+
moped_uri.database
|
112
|
+
else
|
113
|
+
nil
|
114
|
+
end
|
115
|
+
end
|
102
116
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
117
|
+
def collection
|
118
|
+
self['collection'] || 'server_log'
|
119
|
+
end
|
120
|
+
|
121
|
+
def capsize
|
122
|
+
self['capsize'].to_i*1024*1024
|
123
|
+
end
|
124
|
+
|
125
|
+
def moped_uri
|
126
|
+
if self['uri'] && defined? ::Moped::MongoUri
|
127
|
+
::Moped::MongoUri.new(self['uri'])
|
128
|
+
else
|
129
|
+
nil
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
def moped_config
|
134
|
+
args = {}
|
135
|
+
|
136
|
+
if moped_uri
|
137
|
+
args = moped_uri.moped_arguments[1]
|
138
|
+
end
|
139
|
+
|
140
|
+
args[:database] = self.database
|
141
|
+
|
142
|
+
exclude = %w(host port hosts uri collection database capsize)
|
143
|
+
|
144
|
+
@params.each do |key, value|
|
145
|
+
next if exclude.include? key
|
146
|
+
args[key.to_sym] = cast(value)
|
147
|
+
end
|
148
|
+
|
149
|
+
args
|
150
|
+
end
|
151
|
+
|
152
|
+
def moped_arguments
|
153
|
+
[hosts, moped_config]
|
154
|
+
end
|
155
|
+
|
156
|
+
private
|
157
|
+
def cast(value)
|
158
|
+
if value.is_a? String
|
159
|
+
value.to_sym
|
160
|
+
else
|
161
|
+
value
|
162
|
+
end
|
107
163
|
end
|
108
164
|
end
|
109
165
|
end
|
data/spec/config_spec.rb
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'mongo_request_logger/config'
|
3
|
+
require 'mongo'
|
4
|
+
|
5
|
+
include MongoRequestLogger
|
6
|
+
|
7
|
+
describe MongoRequestLogger::Config do
|
8
|
+
|
9
|
+
it "should namespace" do
|
10
|
+
pending
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should handle a simple case" do
|
14
|
+
config = MongoRequestLogger::Config.new({
|
15
|
+
host: 'example.org',
|
16
|
+
port: 1234,
|
17
|
+
database: 'request_logger_test',
|
18
|
+
collection: 'server_log',
|
19
|
+
capsize: 10,
|
20
|
+
})
|
21
|
+
|
22
|
+
config.hosts.should == ['example.org:1234']
|
23
|
+
config.moped_config.should == {database: 'request_logger_test'}
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should default to localhost:27017" do
|
27
|
+
config = MongoRequestLogger::Config.new({
|
28
|
+
database: 'request_logger_test',
|
29
|
+
collection: 'server_log',
|
30
|
+
capsize: 10,
|
31
|
+
})
|
32
|
+
|
33
|
+
config.hosts.should == ['127.0.0.1:27017']
|
34
|
+
config.moped_config.should == {database: 'request_logger_test'}
|
35
|
+
|
36
|
+
config.database.should == 'request_logger_test'
|
37
|
+
config.collection.should == 'server_log'
|
38
|
+
config.capsize.should == 10485760
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should configure with a host array" do
|
42
|
+
config = MongoRequestLogger::Config.new({
|
43
|
+
hosts: [
|
44
|
+
'node1.example.org:27017',
|
45
|
+
'node2.localhost:27017',
|
46
|
+
],
|
47
|
+
database: 'request_logger_test',
|
48
|
+
collection: 'server_log',
|
49
|
+
capsize: 10,
|
50
|
+
})
|
51
|
+
|
52
|
+
config.hosts.should == [
|
53
|
+
'node1.example.org:27017',
|
54
|
+
'node2.localhost:27017',
|
55
|
+
]
|
56
|
+
config.moped_config.should == {database: 'request_logger_test'}
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should pass through options" do
|
60
|
+
# This should work similarly for ssl: true. Unfortunately, we don't have a
|
61
|
+
# ssl host to test against.
|
62
|
+
config = MongoRequestLogger::Config.new({
|
63
|
+
consistency: 'strong',
|
64
|
+
timeout: 30,
|
65
|
+
ssl: true,
|
66
|
+
database: 'request_logger_test',
|
67
|
+
collection: 'server_log',
|
68
|
+
capsize: 10,
|
69
|
+
})
|
70
|
+
|
71
|
+
config.moped_config.should == {
|
72
|
+
timeout: 30,
|
73
|
+
ssl: true,
|
74
|
+
consistency: :strong,
|
75
|
+
database: 'request_logger_test'
|
76
|
+
}
|
77
|
+
end
|
78
|
+
|
79
|
+
context "when configured with an URI" do
|
80
|
+
it "should configure with a single host" do
|
81
|
+
config = MongoRequestLogger::Config.new({
|
82
|
+
uri: 'mongodb://example.org:1234/request_logger_test',
|
83
|
+
collection: 'server_log',
|
84
|
+
capsize: 10
|
85
|
+
})
|
86
|
+
|
87
|
+
config.database.should == 'request_logger_test'
|
88
|
+
config.collection.should == 'server_log'
|
89
|
+
config.capsize.should == 10485760
|
90
|
+
|
91
|
+
config.hosts.should == ['example.org:1234']
|
92
|
+
config.moped_config.should == {database: 'request_logger_test'}
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should configure with multiple hosts" do
|
96
|
+
# We only have a single real host to connect to, so we add it multiple times
|
97
|
+
config = MongoRequestLogger::Config.new({
|
98
|
+
uri: 'mongodb://node1.example.org:1234,node2.example.org:1234/request_logger_test',
|
99
|
+
collection: 'server_log',
|
100
|
+
capsize: 10
|
101
|
+
})
|
102
|
+
|
103
|
+
config.database.should == 'request_logger_test'
|
104
|
+
config.collection.should == 'server_log'
|
105
|
+
|
106
|
+
config.hosts.should == ['node1.example.org:1234', 'node2.example.org:1234']
|
107
|
+
config.moped_config.should == {database: 'request_logger_test'}
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should configure with URI options" do
|
111
|
+
config = MongoRequestLogger::Config.new({
|
112
|
+
uri: 'mongodb://example.org:1234/request_logger_test?consistency=strong&timeout=30&ssl=true',
|
113
|
+
collection: 'server_log',
|
114
|
+
capsize: 10
|
115
|
+
})
|
116
|
+
|
117
|
+
config.database.should == 'request_logger_test'
|
118
|
+
config.collection.should == 'server_log'
|
119
|
+
|
120
|
+
config.hosts.should == ['example.org:1234']
|
121
|
+
config.moped_config.should == {
|
122
|
+
consistency: :strong,
|
123
|
+
timeout: 30,
|
124
|
+
ssl: true,
|
125
|
+
database: 'request_logger_test'
|
126
|
+
}
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
data/spec/moped_logger_spec.rb
CHANGED
@@ -36,4 +36,112 @@ describe 'MongoRequestLogger::Logger with moped' do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
include_examples "log"
|
39
|
+
|
40
|
+
context "when configured with a simple config hash" do
|
41
|
+
it "should configure with a single host" do
|
42
|
+
config = {
|
43
|
+
host: 'localhost',
|
44
|
+
port: 27017,
|
45
|
+
database: 'request_logger_test',
|
46
|
+
collection: 'server_log',
|
47
|
+
capsize: 10,
|
48
|
+
}
|
49
|
+
|
50
|
+
adapter = MongoRequestLogger::Adapters::Moped.new(config)
|
51
|
+
connection = adapter.connection
|
52
|
+
connection.options[:database].should == 'request_logger_test'
|
53
|
+
connection.consistency.should == :eventual # The default
|
54
|
+
connection.cluster.nodes.first.resolved_address.should == '127.0.0.1:27017'
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should configure with a host array" do
|
58
|
+
config = {
|
59
|
+
hosts: [
|
60
|
+
'localhost:27017',
|
61
|
+
'localhost:27017',
|
62
|
+
],
|
63
|
+
database: 'request_logger_test',
|
64
|
+
collection: 'server_log',
|
65
|
+
capsize: 10,
|
66
|
+
}
|
67
|
+
|
68
|
+
adapter = MongoRequestLogger::Adapters::Moped.new(config)
|
69
|
+
connection = adapter.connection
|
70
|
+
connection.options[:database].should == 'request_logger_test'
|
71
|
+
connection.cluster.nodes[0].resolved_address.should == '127.0.0.1:27017'
|
72
|
+
connection.cluster.nodes[1].resolved_address.should == '127.0.0.1:27017'
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should pass through options" do
|
76
|
+
# This should work similarly for ssl: true. Unfortunately, we don't have a
|
77
|
+
# ssl host to test against.
|
78
|
+
config = {
|
79
|
+
host: 'localhost',
|
80
|
+
port: 27017,
|
81
|
+
consistency: 'strong',
|
82
|
+
timeout: 30,
|
83
|
+
database: 'request_logger_test',
|
84
|
+
collection: 'server_log',
|
85
|
+
capsize: 10,
|
86
|
+
}
|
87
|
+
|
88
|
+
adapter = MongoRequestLogger::Adapters::Moped.new(config)
|
89
|
+
connection = adapter.connection
|
90
|
+
connection.options[:database].should == 'request_logger_test'
|
91
|
+
connection.options[:timeout].should == 30
|
92
|
+
connection.options[:consistency].should == :strong
|
93
|
+
connection.consistency.should == :strong
|
94
|
+
|
95
|
+
connection.cluster.nodes[0].resolved_address.should == '127.0.0.1:27017'
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
context "when configured with an URI" do
|
100
|
+
it "should configure with a single host" do
|
101
|
+
config = {
|
102
|
+
uri: 'mongodb://localhost:27017/request_logger_test',
|
103
|
+
collection: 'server_log',
|
104
|
+
capsize: 10,
|
105
|
+
}
|
106
|
+
|
107
|
+
adapter = MongoRequestLogger::Adapters::Moped.new(config)
|
108
|
+
connection = adapter.connection
|
109
|
+
connection.options[:database].should == 'request_logger_test'
|
110
|
+
connection.consistency.should == :eventual # The default
|
111
|
+
connection.cluster.nodes.first.resolved_address.should == '127.0.0.1:27017'
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should configure with multiple hosts" do
|
115
|
+
# We only have a single real host to connect to, so we add it multiple times
|
116
|
+
config = {
|
117
|
+
uri: 'mongodb://localhost:27017,localhost:27017/request_logger_test',
|
118
|
+
collection: 'server_log',
|
119
|
+
capsize: 10,
|
120
|
+
}
|
121
|
+
|
122
|
+
adapter = MongoRequestLogger::Adapters::Moped.new(config)
|
123
|
+
connection = adapter.connection
|
124
|
+
connection.options[:database].should == 'request_logger_test'
|
125
|
+
connection.cluster.nodes[0].resolved_address.should == '127.0.0.1:27017'
|
126
|
+
connection.cluster.nodes[1].resolved_address.should == '127.0.0.1:27017'
|
127
|
+
end
|
128
|
+
|
129
|
+
it "should configure with URI options" do
|
130
|
+
# This should work similarly for ssl=true. Unfortunately, we don't have a
|
131
|
+
# ssl host to test against.
|
132
|
+
config = {
|
133
|
+
uri: 'mongodb://localhost:27017/request_logger_test?consistency=strong',
|
134
|
+
collection: 'server_log',
|
135
|
+
capsize: 10,
|
136
|
+
}
|
137
|
+
|
138
|
+
adapter = MongoRequestLogger::Adapters::Moped.new(config)
|
139
|
+
connection = adapter.connection
|
140
|
+
connection.options[:database].should == 'request_logger_test'
|
141
|
+
connection.options[:consistency].should == :strong
|
142
|
+
connection.consistency.should == :strong
|
143
|
+
|
144
|
+
connection.cluster.nodes[0].resolved_address.should == '127.0.0.1:27017'
|
145
|
+
end
|
146
|
+
end
|
39
147
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongo_request_logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Embark Mobile
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
@@ -63,7 +63,6 @@ files:
|
|
63
63
|
- .travis.yml
|
64
64
|
- CHANGELOG.md
|
65
65
|
- Gemfile
|
66
|
-
- Gemfile.lock
|
67
66
|
- LICENSE.txt
|
68
67
|
- README.md
|
69
68
|
- Rakefile
|
@@ -278,6 +277,7 @@ files:
|
|
278
277
|
- angular/app/img/flags/sn.png
|
279
278
|
- angular/app/img/flags/so.png
|
280
279
|
- angular/app/img/flags/sr.png
|
280
|
+
- angular/app/img/flags/ss.png
|
281
281
|
- angular/app/img/flags/st.png
|
282
282
|
- angular/app/img/flags/sv.png
|
283
283
|
- angular/app/img/flags/sy.png
|
@@ -372,9 +372,7 @@ files:
|
|
372
372
|
- angular/test/unit/servicesSpec.js
|
373
373
|
- config.ru
|
374
374
|
- gemfiles/sinatra1.3.gemfile
|
375
|
-
- gemfiles/sinatra1.3.gemfile.lock
|
376
375
|
- gemfiles/sinatra1.4.gemfile
|
377
|
-
- gemfiles/sinatra1.4.gemfile.lock
|
378
376
|
- lib/mongo_request_logger.rb
|
379
377
|
- lib/mongo_request_logger/adapters/base.rb
|
380
378
|
- lib/mongo_request_logger/adapters/mongo.rb
|
@@ -393,6 +391,7 @@ files:
|
|
393
391
|
- lib/mongo_request_logger/version.rb
|
394
392
|
- lib/mongo_request_logger/viewer.rb
|
395
393
|
- mongo_request_logger.gemspec
|
394
|
+
- spec/config_spec.rb
|
396
395
|
- spec/dummy/application.rb
|
397
396
|
- spec/dummy/config/logger.yml
|
398
397
|
- spec/dummy/log/.gitkeep
|
@@ -427,11 +426,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
427
426
|
version: '0'
|
428
427
|
requirements: []
|
429
428
|
rubyforge_project:
|
430
|
-
rubygems_version: 2.0.
|
429
|
+
rubygems_version: 2.0.3
|
431
430
|
signing_key:
|
432
431
|
specification_version: 4
|
433
432
|
summary: Structured logger and log viewer for Rack (including Rails) requests
|
434
433
|
test_files:
|
434
|
+
- spec/config_spec.rb
|
435
435
|
- spec/dummy/application.rb
|
436
436
|
- spec/dummy/config/logger.yml
|
437
437
|
- spec/dummy/log/.gitkeep
|
data/Gemfile.lock
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
mongo_request_logger (0.2.7)
|
5
|
-
activesupport (~> 3.0)
|
6
|
-
sinatra (>= 1.3.2)
|
7
|
-
sinatra-contrib
|
8
|
-
|
9
|
-
GEM
|
10
|
-
remote: https://rubygems.org/
|
11
|
-
specs:
|
12
|
-
activesupport (3.2.13)
|
13
|
-
i18n (= 0.6.1)
|
14
|
-
multi_json (~> 1.0)
|
15
|
-
backports (3.3.3)
|
16
|
-
bson (1.8.5)
|
17
|
-
bson_ext (1.8.5)
|
18
|
-
bson (~> 1.8.5)
|
19
|
-
diff-lcs (1.2.3)
|
20
|
-
eventmachine (1.0.3)
|
21
|
-
i18n (0.6.1)
|
22
|
-
mongo (1.8.5)
|
23
|
-
bson (~> 1.8.5)
|
24
|
-
moped (1.4.5)
|
25
|
-
multi_json (1.7.7)
|
26
|
-
rack (1.5.2)
|
27
|
-
rack-protection (1.5.0)
|
28
|
-
rack
|
29
|
-
rack-test (0.6.2)
|
30
|
-
rack (>= 1.0)
|
31
|
-
rspec (2.13.0)
|
32
|
-
rspec-core (~> 2.13.0)
|
33
|
-
rspec-expectations (~> 2.13.0)
|
34
|
-
rspec-mocks (~> 2.13.0)
|
35
|
-
rspec-core (2.13.1)
|
36
|
-
rspec-expectations (2.13.0)
|
37
|
-
diff-lcs (>= 1.1.3, < 2.0)
|
38
|
-
rspec-mocks (2.13.1)
|
39
|
-
sinatra (1.4.2)
|
40
|
-
rack (~> 1.5, >= 1.5.2)
|
41
|
-
rack-protection (~> 1.4)
|
42
|
-
tilt (~> 1.3, >= 1.3.4)
|
43
|
-
sinatra-contrib (1.4.0)
|
44
|
-
backports (>= 2.0)
|
45
|
-
eventmachine
|
46
|
-
rack-protection
|
47
|
-
rack-test
|
48
|
-
sinatra (~> 1.4.2)
|
49
|
-
tilt (~> 1.3)
|
50
|
-
tilt (1.3.7)
|
51
|
-
|
52
|
-
PLATFORMS
|
53
|
-
ruby
|
54
|
-
|
55
|
-
DEPENDENCIES
|
56
|
-
bson_ext
|
57
|
-
mongo
|
58
|
-
mongo_request_logger!
|
59
|
-
moped
|
60
|
-
rspec
|
61
|
-
sinatra (~> 1.4.0)
|
@@ -1,130 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: /Users/john/src/mongo_request_logger
|
3
|
-
specs:
|
4
|
-
mongo_request_logger (0.2.7)
|
5
|
-
activesupport (~> 3.0)
|
6
|
-
sinatra (>= 1.3.2)
|
7
|
-
sinatra-contrib
|
8
|
-
|
9
|
-
GEM
|
10
|
-
remote: https://rubygems.org/
|
11
|
-
specs:
|
12
|
-
actionmailer (3.2.13)
|
13
|
-
actionpack (= 3.2.13)
|
14
|
-
mail (~> 2.5.3)
|
15
|
-
actionpack (3.2.13)
|
16
|
-
activemodel (= 3.2.13)
|
17
|
-
activesupport (= 3.2.13)
|
18
|
-
builder (~> 3.0.0)
|
19
|
-
erubis (~> 2.7.0)
|
20
|
-
journey (~> 1.0.4)
|
21
|
-
rack (~> 1.4.5)
|
22
|
-
rack-cache (~> 1.2)
|
23
|
-
rack-test (~> 0.6.1)
|
24
|
-
sprockets (~> 2.2.1)
|
25
|
-
activemodel (3.2.13)
|
26
|
-
activesupport (= 3.2.13)
|
27
|
-
builder (~> 3.0.0)
|
28
|
-
activerecord (3.2.13)
|
29
|
-
activemodel (= 3.2.13)
|
30
|
-
activesupport (= 3.2.13)
|
31
|
-
arel (~> 3.0.2)
|
32
|
-
tzinfo (~> 0.3.29)
|
33
|
-
activeresource (3.2.13)
|
34
|
-
activemodel (= 3.2.13)
|
35
|
-
activesupport (= 3.2.13)
|
36
|
-
activesupport (3.2.13)
|
37
|
-
i18n (= 0.6.1)
|
38
|
-
multi_json (~> 1.0)
|
39
|
-
arel (3.0.2)
|
40
|
-
backports (3.3.3)
|
41
|
-
bson (1.8.5)
|
42
|
-
bson_ext (1.8.5)
|
43
|
-
bson (~> 1.8.5)
|
44
|
-
builder (3.0.4)
|
45
|
-
diff-lcs (1.2.3)
|
46
|
-
erubis (2.7.0)
|
47
|
-
eventmachine (1.0.3)
|
48
|
-
hike (1.2.2)
|
49
|
-
i18n (0.6.1)
|
50
|
-
journey (1.0.4)
|
51
|
-
json (1.7.7)
|
52
|
-
mail (2.5.3)
|
53
|
-
i18n (>= 0.4.0)
|
54
|
-
mime-types (~> 1.16)
|
55
|
-
treetop (~> 1.4.8)
|
56
|
-
mime-types (1.22)
|
57
|
-
mongo (1.8.5)
|
58
|
-
bson (~> 1.8.5)
|
59
|
-
moped (1.4.5)
|
60
|
-
multi_json (1.7.2)
|
61
|
-
polyglot (0.3.3)
|
62
|
-
rack (1.4.5)
|
63
|
-
rack-cache (1.2)
|
64
|
-
rack (>= 0.4)
|
65
|
-
rack-protection (1.5.0)
|
66
|
-
rack
|
67
|
-
rack-ssl (1.3.3)
|
68
|
-
rack
|
69
|
-
rack-test (0.6.2)
|
70
|
-
rack (>= 1.0)
|
71
|
-
rails (3.2.13)
|
72
|
-
actionmailer (= 3.2.13)
|
73
|
-
actionpack (= 3.2.13)
|
74
|
-
activerecord (= 3.2.13)
|
75
|
-
activeresource (= 3.2.13)
|
76
|
-
activesupport (= 3.2.13)
|
77
|
-
bundler (~> 1.0)
|
78
|
-
railties (= 3.2.13)
|
79
|
-
railties (3.2.13)
|
80
|
-
actionpack (= 3.2.13)
|
81
|
-
activesupport (= 3.2.13)
|
82
|
-
rack-ssl (~> 1.3.2)
|
83
|
-
rake (>= 0.8.7)
|
84
|
-
rdoc (~> 3.4)
|
85
|
-
thor (>= 0.14.6, < 2.0)
|
86
|
-
rake (10.0.4)
|
87
|
-
rdoc (3.12.2)
|
88
|
-
json (~> 1.4)
|
89
|
-
rspec (2.13.0)
|
90
|
-
rspec-core (~> 2.13.0)
|
91
|
-
rspec-expectations (~> 2.13.0)
|
92
|
-
rspec-mocks (~> 2.13.0)
|
93
|
-
rspec-core (2.13.1)
|
94
|
-
rspec-expectations (2.13.0)
|
95
|
-
diff-lcs (>= 1.1.3, < 2.0)
|
96
|
-
rspec-mocks (2.13.1)
|
97
|
-
sinatra (1.3.6)
|
98
|
-
rack (~> 1.4)
|
99
|
-
rack-protection (~> 1.3)
|
100
|
-
tilt (~> 1.3, >= 1.3.3)
|
101
|
-
sinatra-contrib (1.3.2)
|
102
|
-
backports (>= 2.0)
|
103
|
-
eventmachine
|
104
|
-
rack-protection
|
105
|
-
rack-test
|
106
|
-
sinatra (~> 1.3.0)
|
107
|
-
tilt (~> 1.3)
|
108
|
-
sprockets (2.2.2)
|
109
|
-
hike (~> 1.2)
|
110
|
-
multi_json (~> 1.0)
|
111
|
-
rack (~> 1.0)
|
112
|
-
tilt (~> 1.1, != 1.3.0)
|
113
|
-
thor (0.18.1)
|
114
|
-
tilt (1.3.7)
|
115
|
-
treetop (1.4.12)
|
116
|
-
polyglot
|
117
|
-
polyglot (>= 0.3.1)
|
118
|
-
tzinfo (0.3.37)
|
119
|
-
|
120
|
-
PLATFORMS
|
121
|
-
ruby
|
122
|
-
|
123
|
-
DEPENDENCIES
|
124
|
-
bson_ext
|
125
|
-
mongo
|
126
|
-
mongo_request_logger!
|
127
|
-
moped
|
128
|
-
rails (~> 3.2.10)
|
129
|
-
rspec
|
130
|
-
sinatra (~> 1.3.2)
|
@@ -1,61 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: /Users/john/src/mongo_request_logger
|
3
|
-
specs:
|
4
|
-
mongo_request_logger (0.2.7)
|
5
|
-
activesupport (~> 3.0)
|
6
|
-
sinatra (>= 1.3.2)
|
7
|
-
sinatra-contrib
|
8
|
-
|
9
|
-
GEM
|
10
|
-
remote: https://rubygems.org/
|
11
|
-
specs:
|
12
|
-
activesupport (3.2.13)
|
13
|
-
i18n (= 0.6.1)
|
14
|
-
multi_json (~> 1.0)
|
15
|
-
backports (3.3.3)
|
16
|
-
bson (1.8.5)
|
17
|
-
bson_ext (1.8.5)
|
18
|
-
bson (~> 1.8.5)
|
19
|
-
diff-lcs (1.2.3)
|
20
|
-
eventmachine (1.0.3)
|
21
|
-
i18n (0.6.1)
|
22
|
-
mongo (1.8.5)
|
23
|
-
bson (~> 1.8.5)
|
24
|
-
moped (1.4.5)
|
25
|
-
multi_json (1.7.7)
|
26
|
-
rack (1.5.2)
|
27
|
-
rack-protection (1.5.0)
|
28
|
-
rack
|
29
|
-
rack-test (0.6.2)
|
30
|
-
rack (>= 1.0)
|
31
|
-
rspec (2.13.0)
|
32
|
-
rspec-core (~> 2.13.0)
|
33
|
-
rspec-expectations (~> 2.13.0)
|
34
|
-
rspec-mocks (~> 2.13.0)
|
35
|
-
rspec-core (2.13.1)
|
36
|
-
rspec-expectations (2.13.0)
|
37
|
-
diff-lcs (>= 1.1.3, < 2.0)
|
38
|
-
rspec-mocks (2.13.1)
|
39
|
-
sinatra (1.4.2)
|
40
|
-
rack (~> 1.5, >= 1.5.2)
|
41
|
-
rack-protection (~> 1.4)
|
42
|
-
tilt (~> 1.3, >= 1.3.4)
|
43
|
-
sinatra-contrib (1.4.0)
|
44
|
-
backports (>= 2.0)
|
45
|
-
eventmachine
|
46
|
-
rack-protection
|
47
|
-
rack-test
|
48
|
-
sinatra (~> 1.4.2)
|
49
|
-
tilt (~> 1.3)
|
50
|
-
tilt (1.3.7)
|
51
|
-
|
52
|
-
PLATFORMS
|
53
|
-
ruby
|
54
|
-
|
55
|
-
DEPENDENCIES
|
56
|
-
bson_ext
|
57
|
-
mongo
|
58
|
-
mongo_request_logger!
|
59
|
-
moped
|
60
|
-
rspec
|
61
|
-
sinatra (~> 1.4.0)
|