mongodb_logger 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.ruby-version +1 -0
- data/.travis.yml +1 -2
- data/CHANGELOG.md +7 -0
- data/app/assets/javascripts/logs.js.coffee +1 -0
- data/lib/mongodb_logger.rb +4 -10
- data/lib/mongodb_logger/adapters/mongo.rb +6 -6
- data/lib/mongodb_logger/adapters/moped.rb +2 -2
- data/lib/mongodb_logger/initializer_mixin.rb +6 -4
- data/lib/mongodb_logger/logger.rb +2 -1
- data/lib/mongodb_logger/server.rb +5 -55
- data/lib/mongodb_logger/server/helpers/view_helpers.rb +12 -34
- data/lib/mongodb_logger/server/routes/analytic.rb +16 -0
- data/lib/mongodb_logger/server/routes/logs.rb +46 -0
- data/lib/mongodb_logger/server/views/shared/layout/_mustache.erb +1 -1
- data/lib/mongodb_logger/tagged_logger.rb +9 -0
- data/lib/mongodb_logger/utils/migrate.rb +13 -8
- data/lib/mongodb_logger/version.rb +1 -1
- data/mongodb_logger.gemspec +1 -1
- data/spec/factories/config/database_with_ssl.yml +7 -0
- data/spec/mongodb_logger_spec.rb +15 -1
- data/spec/rails_spec/controllers/tests_controller_spec_rails.rb +7 -0
- data/spec/spec_helper.rb +0 -1
- data/spec/support/mongodb_logger_helper.rb +1 -0
- data/spec/utils/migrate_spec.rb +1 -1
- data/tasks/mongodb_logger.rake +1 -1
- metadata +14 -9
- data/.rvmrc +0 -1
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.0.0
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/lib/mongodb_logger.rb
CHANGED
@@ -4,13 +4,14 @@ require 'mongodb_logger/config'
|
|
4
4
|
require 'mongodb_logger/logger'
|
5
5
|
require 'mongodb_logger/railtie' if defined?(Rails::Railtie)
|
6
6
|
require 'mongodb_logger/engine' if defined?(Rails::Engine)
|
7
|
+
require 'mongodb_logger/tagged_logger' if defined?(ActiveSupport::TaggedLogging)
|
7
8
|
require 'mongodb_logger/rack_middleware'
|
8
9
|
require 'mongodb_logger/version'
|
9
10
|
|
10
11
|
module MongodbLogger
|
11
12
|
module Base
|
12
13
|
extend Config
|
13
|
-
|
14
|
+
|
14
15
|
def self.included(base)
|
15
16
|
base.class_eval do
|
16
17
|
begin
|
@@ -23,21 +24,14 @@ module MongodbLogger
|
|
23
24
|
|
24
25
|
def enable_mongodb_logger
|
25
26
|
return yield unless Rails.logger.respond_to?(:mongoize)
|
26
|
-
|
27
|
-
when request.respond_to?(:filtered_parameters) then request.filtered_parameters
|
28
|
-
else params
|
29
|
-
end
|
30
|
-
f_session = case
|
31
|
-
when request.respond_to?(:session) then request.session
|
32
|
-
else session
|
33
|
-
end
|
27
|
+
f_session = (request.respond_to?(:session) ? request.session : session)
|
34
28
|
Rails.logger.mongoize({
|
35
29
|
:method => request.method,
|
36
30
|
:action => action_name,
|
37
31
|
:controller => controller_name,
|
38
32
|
:path => request.path,
|
39
33
|
:url => request.url,
|
40
|
-
:params =>
|
34
|
+
:params => (request.respond_to?(:filtered_parameters) ? request.filtered_parameters : params),
|
41
35
|
:session => mongo_fix_session_keys(f_session),
|
42
36
|
:ip => request.remote_ip
|
43
37
|
}) { yield }
|
@@ -75,16 +75,16 @@ module MongodbLogger
|
|
75
75
|
|
76
76
|
def mongo_connection_object
|
77
77
|
if @configuration['hosts']
|
78
|
-
conn = ::Mongo::
|
79
|
-
|
78
|
+
conn = ::Mongo::MongoReplicaSetClient.new(@configuration['hosts'],
|
79
|
+
:pool_timeout => 6, :ssl => @configuration['ssl'])
|
80
80
|
@configuration['replica_set'] = true
|
81
81
|
elsif @configuration['url']
|
82
|
-
conn = ::Mongo::
|
82
|
+
conn = ::Mongo::MongoClient.from_uri(@configuration['url'])
|
83
83
|
else
|
84
|
-
conn = ::Mongo::
|
84
|
+
conn = ::Mongo::MongoClient.new(@configuration['host'],
|
85
85
|
@configuration['port'],
|
86
|
-
:
|
87
|
-
:
|
86
|
+
:pool_timeout => 6,
|
87
|
+
:ssl => @configuration['ssl'])
|
88
88
|
end
|
89
89
|
@connection_type = conn.class
|
90
90
|
conn
|
@@ -85,12 +85,12 @@ module MongodbLogger
|
|
85
85
|
|
86
86
|
def mongo_connection_object
|
87
87
|
if @configuration['hosts']
|
88
|
-
conn = ::Moped::Session.new(@configuration['hosts'].map{|(host,port)| "#{host}:#{port}"}, :timeout => 6)
|
88
|
+
conn = ::Moped::Session.new(@configuration['hosts'].map{|(host,port)| "#{host}:#{port}"}, :timeout => 6, :ssl => @configuration['ssl'])
|
89
89
|
@configuration['replica_set'] = true
|
90
90
|
elsif @configuration['url']
|
91
91
|
conn = ::Moped::Session.connect(@configuration['url'])
|
92
92
|
else
|
93
|
-
conn = ::Moped::Session.new(["#{@configuration['host']}:#{@configuration['port']}"], :timeout => 6)
|
93
|
+
conn = ::Moped::Session.new(["#{@configuration['host']}:#{@configuration['port']}"], :timeout => 6, :ssl => @configuration['ssl'])
|
94
94
|
end
|
95
95
|
@connection_type = conn.class
|
96
96
|
conn
|
@@ -1,14 +1,16 @@
|
|
1
1
|
module MongodbLogger
|
2
2
|
module InitializerMixin
|
3
|
-
|
3
|
+
|
4
4
|
def rails3(minor = 0)
|
5
5
|
3 == Rails::VERSION::MAJOR && minor == Rails::VERSION::MINOR
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
8
|
def create_logger(config)
|
9
9
|
path = config.paths['log'].first
|
10
10
|
level = ActiveSupport::BufferedLogger.const_get(config.log_level.to_s.upcase)
|
11
11
|
logger = MongodbLogger::Logger.new(:path => path, :level => level)
|
12
|
+
# decorating with TaggedLogging
|
13
|
+
logger = MongodbLogger::TaggedLogger.new(logger) if defined?(ActiveSupport::TaggedLogging)
|
12
14
|
logger.level = level
|
13
15
|
logger.auto_flushing = false if Rails.env.production? && rails3(1)
|
14
16
|
logger
|
@@ -22,6 +24,6 @@ module MongodbLogger
|
|
22
24
|
)
|
23
25
|
logger
|
24
26
|
end
|
25
|
-
|
27
|
+
|
26
28
|
end
|
27
|
-
end
|
29
|
+
end
|
@@ -111,7 +111,8 @@ module MongodbLogger
|
|
111
111
|
@db_configuration = {
|
112
112
|
'host' => 'localhost',
|
113
113
|
'port' => 27017,
|
114
|
-
'capsize' => default_capsize
|
114
|
+
'capsize' => default_capsize,
|
115
|
+
'ssl' => false}.merge(resolve_config)
|
115
116
|
@db_configuration['collection'] ||= defined?(Rails) ? "#{Rails.env}_log" : "production_log"
|
116
117
|
@db_configuration['application_name'] ||= resolve_application_name
|
117
118
|
@db_configuration['write_options'] ||= { w: 0, wtimeout: 200 }
|
@@ -58,68 +58,18 @@ module MongodbLogger
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
|
62
61
|
get "/?" do
|
63
62
|
redirect url_path(:overview)
|
64
63
|
end
|
65
64
|
|
66
|
-
get "/overview/?" do
|
67
|
-
@filter = ServerModel::Filter.new(params[:filter])
|
68
|
-
@logs = @mongo_adapter.filter_by_conditions(@filter)
|
69
|
-
show :overview, !request.xhr?
|
70
|
-
end
|
71
|
-
|
72
|
-
# log info
|
73
|
-
get "/log/:id" do
|
74
|
-
@log = @mongo_adapter.find_by_id(params[:id])
|
75
|
-
show :show_log, !request.xhr?
|
76
|
-
end
|
77
|
-
|
78
|
-
get "/tail_logs/?:log_last_id?" do
|
79
|
-
@info = @mongo_adapter.tail_log_from_params(params)
|
80
|
-
@info.merge!(
|
81
|
-
:content => @info[:logs].map{ |log| partial(:"shared/log", :object => log) }.join("\n"),
|
82
|
-
:collection_stats => partial(:"shared/collection_stats", :object => @collection_stats)
|
83
|
-
)
|
84
|
-
content_type :json
|
85
|
-
MultiJson.dump(@info)
|
86
|
-
end
|
87
|
-
|
88
|
-
get "/changed_filter/:type" do
|
89
|
-
type_id = ServerModel::AdditionalFilter.get_type_index params[:type]
|
90
|
-
conditions = ServerModel::AdditionalFilter::VAR_TYPE_CONDITIONS[type_id]
|
91
|
-
values = ServerModel::AdditionalFilter::VAR_TYPE_VALUES[type_id]
|
92
|
-
|
93
|
-
content_type :json
|
94
|
-
MultiJson.dump({
|
95
|
-
:type_id => type_id,
|
96
|
-
:conditions => conditions,
|
97
|
-
:values => values
|
98
|
-
})
|
99
|
-
end
|
100
|
-
|
101
|
-
get "/add_filter/?" do
|
102
|
-
@filter = ServerModel::Filter.new(nil)
|
103
|
-
@filter_more = ServerModel::AdditionalFilter.new(nil, @filter)
|
104
|
-
partial(:"shared/dynamic_filter", :object => @filter_more)
|
105
|
-
end
|
106
|
-
|
107
|
-
# analytics
|
108
|
-
%w( analytics ).each do |page|
|
109
|
-
get "/#{page}/?" do
|
110
|
-
@analytic = ServerModel::Analytic.new(@mongo_adapter, params[:analytic])
|
111
|
-
show page, !request.xhr?
|
112
|
-
end
|
113
|
-
post "/#{page}/?" do
|
114
|
-
@analytic = ServerModel::Analytic.new(@mongo_adapter, params[:analytic])
|
115
|
-
content_type :json
|
116
|
-
MultiJson.dump(@analytic.get_data)
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
65
|
error do
|
121
66
|
erb :error, { :layout => false }, :error => 'Sorry there was a nasty error. Maybe no connection to MongoDB. Debug: ' + env['sinatra.error'].inspect + '<br />' + env.inspect
|
122
67
|
end
|
123
68
|
|
124
69
|
end
|
125
70
|
end
|
71
|
+
|
72
|
+
# routes
|
73
|
+
%w{logs analytic}.each do |route|
|
74
|
+
require File.join(File.dirname(File.expand_path(__FILE__)), "server", "routes", route)
|
75
|
+
end
|
@@ -22,13 +22,7 @@ module Sinatra::ViewHelpers
|
|
22
22
|
rescue ArgumentError, TypeError
|
23
23
|
return number
|
24
24
|
end
|
25
|
-
|
26
|
-
Float(number)
|
27
|
-
rescue ArgumentError, TypeError
|
28
|
-
return number
|
29
|
-
end
|
30
|
-
base = 1024
|
31
|
-
max_exp = STORAGE_UNITS.size - 1
|
25
|
+
base, max_exp = 1024, STORAGE_UNITS.size - 1
|
32
26
|
exponent = (Math.log(number) / Math.log(base)).to_i # Convert to base
|
33
27
|
exponent = max_exp if exponent > max_exp # we need this to avoid overflow for the highest unit
|
34
28
|
number /= base ** exponent
|
@@ -42,52 +36,36 @@ module Sinatra::ViewHelpers
|
|
42
36
|
value = ""
|
43
37
|
value = options.delete(:value) if options[:value]
|
44
38
|
value = object.send name if object && object.respond_to?(name)
|
45
|
-
|
46
|
-
|
47
|
-
attr << "#{key}='#{val}'"
|
48
|
-
end
|
49
|
-
"<input type='text' name='#{object.form_name}[#{name.to_s}]' value='#{value}' #{attr.join(" ")} />"
|
39
|
+
attributes = options.map{ |key, val| "#{key}='#{val}'" }
|
40
|
+
"<input type='text' name='#{object.form_name}[#{name.to_s}]' value='#{value}' #{attributes.join(" ")} />"
|
50
41
|
end
|
51
42
|
|
52
43
|
def submit_tag(name, value, options = {})
|
53
|
-
|
54
|
-
|
55
|
-
attr << "#{key}='#{val}'"
|
56
|
-
end
|
57
|
-
"<input type='submit' name='#{name.to_s}' value='#{value}' #{attr.join(" ")} />"
|
44
|
+
attributes = options.map{ |key, val| "#{key}='#{val}'" }
|
45
|
+
"<input type='submit' name='#{name.to_s}' value='#{value}' #{attributes.join(" ")} />"
|
58
46
|
end
|
59
47
|
|
60
48
|
def check_box_tag(object, name, options = {})
|
61
49
|
value = nil
|
62
50
|
value = options.delete(:value) if options[:value]
|
63
51
|
value = object.send name if object && object.respond_to?(name)
|
64
|
-
|
65
|
-
|
66
|
-
attr << "#{key}='#{val}'"
|
67
|
-
end
|
68
|
-
"<input id='#{object.form_name}_#{name.to_s}' type='checkbox' name='#{object.form_name}[#{name.to_s}]' #{'checked="checked"' if value} value='1' #{attr.join(" ")} />"
|
52
|
+
attributes = options.map{ |key, val| "#{key}='#{val}'" }
|
53
|
+
"<input id='#{object.form_name}_#{name.to_s}' type='checkbox' name='#{object.form_name}[#{name.to_s}]' #{'checked="checked"' if value} value='1' #{attributes.join(" ")} />"
|
69
54
|
end
|
70
55
|
|
71
56
|
def label_tag(object, name, label, options = {})
|
72
|
-
|
73
|
-
|
74
|
-
attr << "#{key}='#{val}'"
|
75
|
-
end
|
76
|
-
"<label for='#{object.form_name}_#{name.to_s}' #{attr.join(" ")}>#{label}</label>"
|
57
|
+
attributes = options.map{ |key, val| "#{key}='#{val}'" }
|
58
|
+
"<label for='#{object.form_name}_#{name.to_s}' #{attributes.join(" ")}>#{label}</label>"
|
77
59
|
end
|
78
60
|
|
79
61
|
def select_tag(object, name, options_array, options = {})
|
80
62
|
value = nil
|
81
63
|
value = options.delete(:value) if options[:value]
|
82
64
|
value = object.send name if object && object.respond_to?(name)
|
83
|
-
|
84
|
-
|
85
|
-
attr << "#{key}='#{val}'"
|
86
|
-
end
|
87
|
-
select_tag = []
|
88
|
-
select_tag << "<select id='#{object.form_name}_#{name.to_s}' name='#{object.form_name}[#{name.to_s}]' #{attr.join(" ")}>"
|
65
|
+
attributes = options.map{ |key, val| "#{key}='#{val}'" }
|
66
|
+
select_tag = ["<select id='#{object.form_name}_#{name.to_s}' name='#{object.form_name}[#{name.to_s}]' #{attributes.join(" ")}>"]
|
89
67
|
options_array.each do |val|
|
90
|
-
if val.is_a?(Array)
|
68
|
+
if val.is_a?(Array)
|
91
69
|
skey, sval = val[0], val[1]
|
92
70
|
else
|
93
71
|
skey = sval = val
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module MongodbLogger
|
2
|
+
class Server < Sinatra::Base
|
3
|
+
|
4
|
+
%w( analytics ).each do |page|
|
5
|
+
get "/#{page}/?" do
|
6
|
+
@analytic = ServerModel::Analytic.new(@mongo_adapter, params[:analytic])
|
7
|
+
show page, !request.xhr?
|
8
|
+
end
|
9
|
+
post "/#{page}/?" do
|
10
|
+
@analytic = ServerModel::Analytic.new(@mongo_adapter, params[:analytic])
|
11
|
+
content_type :json
|
12
|
+
MultiJson.dump(@analytic.get_data)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module MongodbLogger
|
2
|
+
class Server < Sinatra::Base
|
3
|
+
|
4
|
+
get "/overview/?" do
|
5
|
+
@filter = ServerModel::Filter.new(params[:filter])
|
6
|
+
@logs = @mongo_adapter.filter_by_conditions(@filter)
|
7
|
+
show :overview, !request.xhr?
|
8
|
+
end
|
9
|
+
|
10
|
+
# log info
|
11
|
+
get "/log/:id" do
|
12
|
+
@log = @mongo_adapter.find_by_id(params[:id])
|
13
|
+
show :show_log, !request.xhr?
|
14
|
+
end
|
15
|
+
|
16
|
+
get "/tail_logs/?:log_last_id?" do
|
17
|
+
@info = @mongo_adapter.tail_log_from_params(params)
|
18
|
+
@info.merge!(
|
19
|
+
:content => @info[:logs].map{ |log| partial(:"shared/log", :object => log) }.join("\n"),
|
20
|
+
:collection_stats => partial(:"shared/collection_stats", :object => @collection_stats)
|
21
|
+
)
|
22
|
+
content_type :json
|
23
|
+
MultiJson.dump(@info)
|
24
|
+
end
|
25
|
+
|
26
|
+
get "/changed_filter/:type" do
|
27
|
+
type_id = ServerModel::AdditionalFilter.get_type_index params[:type]
|
28
|
+
conditions = ServerModel::AdditionalFilter::VAR_TYPE_CONDITIONS[type_id]
|
29
|
+
values = ServerModel::AdditionalFilter::VAR_TYPE_VALUES[type_id]
|
30
|
+
|
31
|
+
content_type :json
|
32
|
+
MultiJson.dump({
|
33
|
+
:type_id => type_id,
|
34
|
+
:conditions => conditions,
|
35
|
+
:values => values
|
36
|
+
})
|
37
|
+
end
|
38
|
+
|
39
|
+
get "/add_filter/?" do
|
40
|
+
@filter = ServerModel::Filter.new(nil)
|
41
|
+
@filter_more = ServerModel::AdditionalFilter.new(nil, @filter)
|
42
|
+
partial(:"shared/dynamic_filter", :object => @filter_more)
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<script type="text/javascript">
|
2
2
|
window.MustacheTemplates = {};
|
3
3
|
<% Dir["#{File.expand_path(File.join(@main_dir, "server", "templates"))}/**/*.mustache"].each do |template| %>
|
4
|
-
window.MustacheTemplates[<%= template.split(File::SEPARATOR).last(2).join("/").gsub(".mustache", "").inspect %>] = Mustache.compile(<%= File.open(template, 'rb').read.inspect %>)
|
4
|
+
window.MustacheTemplates[<%= template.split(File::SEPARATOR).last(2).join("/").gsub(".mustache", "").inspect %>] = Mustache.compile(<%= File.open(template, 'rb').read.inspect %>);
|
5
5
|
<% end %>
|
6
6
|
</script>
|
@@ -7,24 +7,29 @@ module MongodbLogger
|
|
7
7
|
|
8
8
|
def initialize
|
9
9
|
raise "this task work only in Rails app" unless defined?(Rails)
|
10
|
+
end
|
11
|
+
|
12
|
+
def run
|
10
13
|
Progressbar.new.show("Importing data to new capped collection") do
|
11
|
-
|
12
|
-
|
13
|
-
@mongo_adapter = mongodb_logger.mongo_adapter
|
14
|
-
@migrate_logger = create_migration_collection(mongodb_logger.db_configuration)
|
14
|
+
@mongo_adapter, collection_name = get_mongo_adapter_and_name
|
15
|
+
@migrate_logger = create_migration_collection(Rails.logger.db_configuration)
|
15
16
|
|
16
|
-
iterator = 0
|
17
|
-
all_count = @mongo_adapter.collection.find.count
|
17
|
+
iterator, all_count = 0, @mongo_adapter.collection.find.count
|
18
18
|
@mongo_adapter.collection.find.each do |row|
|
19
19
|
@migrate_logger.mongo_adapter.collection.insert(row)
|
20
|
-
iterator += 1
|
21
|
-
progress ((iterator.to_f / all_count.to_f) * 100).round
|
20
|
+
progress (((iterator += 1).to_f / all_count.to_f) * 100).round
|
22
21
|
end if all_count > 0
|
23
22
|
progress 100
|
24
23
|
@migrate_logger.mongo_adapter.rename_collection(collection_name, true)
|
25
24
|
end
|
26
25
|
end
|
27
26
|
|
27
|
+
def get_mongo_adapter_and_name
|
28
|
+
mongodb_logger = Rails.logger
|
29
|
+
collection_name = mongodb_logger.db_configuration['collection'].dup
|
30
|
+
[mongodb_logger.mongo_adapter, collection_name]
|
31
|
+
end
|
32
|
+
|
28
33
|
def create_migration_collection(configuration)
|
29
34
|
configuration.merge!({ 'collection' => "#{configuration['collection']}_copy_#{rand(100)}" })
|
30
35
|
migrate_logger = MongoMigrateLogger.new(configuration)
|
data/mongodb_logger.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |gem|
|
|
19
19
|
gem.add_development_dependency "mocha"
|
20
20
|
gem.add_development_dependency "cucumber"
|
21
21
|
gem.add_development_dependency "cucumber-rails"
|
22
|
-
gem.add_development_dependency "capybara"
|
22
|
+
gem.add_development_dependency "capybara", '2.0.3'
|
23
23
|
gem.add_development_dependency "coffee-script"
|
24
24
|
gem.add_development_dependency "uglifier"
|
25
25
|
gem.add_development_dependency "jasmine"
|
data/spec/mongodb_logger_spec.rb
CHANGED
@@ -71,10 +71,11 @@ describe MongodbLogger::Logger do
|
|
71
71
|
@mongo_adapter = @mongodb_logger.mongo_adapter
|
72
72
|
end
|
73
73
|
|
74
|
-
it "set the default host, port, and capsize if not configured" do
|
74
|
+
it "set the default host, port, ssl and capsize if not configured" do
|
75
75
|
@mongo_adapter.configuration['host'].should == 'localhost'
|
76
76
|
@mongo_adapter.configuration['port'].should == 27017
|
77
77
|
@mongo_adapter.configuration['capsize'].should == MongodbLogger::Logger::DEFAULT_COLLECTION_SIZE
|
78
|
+
@mongo_adapter.configuration['ssl'].should == false
|
78
79
|
end
|
79
80
|
|
80
81
|
it "set the mongo collection name depending on the Rails environment" do
|
@@ -106,6 +107,19 @@ describe MongodbLogger::Logger do
|
|
106
107
|
|
107
108
|
end
|
108
109
|
|
110
|
+
context "ssl" do
|
111
|
+
before do
|
112
|
+
setup_for_config(MongodbLogger::SpecHelper::DEFAULT_CONFIG_WITH_SSL, MongodbLogger::SpecHelper::DEFAULT_CONFIG)
|
113
|
+
end
|
114
|
+
after do
|
115
|
+
cleanup_for_config(MongodbLogger::SpecHelper::DEFAULT_CONFIG)
|
116
|
+
end
|
117
|
+
|
118
|
+
it "be true" do
|
119
|
+
@mongodb_logger.db_configuration['ssl'].should == true
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
109
123
|
end
|
110
124
|
|
111
125
|
context "after instantiation" do
|
@@ -42,6 +42,13 @@ describe TestsController do
|
|
42
42
|
record = @collection.find.first
|
43
43
|
@collection.find.first['method'].should == "GET"
|
44
44
|
end
|
45
|
+
|
46
|
+
it "add_metadata should work" do
|
47
|
+
get :index
|
48
|
+
record = @collection.find.first
|
49
|
+
record['user_id'].should == described_class::LOG_USER_ID
|
50
|
+
record['application_name_again'].should == Rails.root.basename.to_s
|
51
|
+
end
|
45
52
|
end
|
46
53
|
|
47
54
|
describe "POST #create" do
|
data/spec/spec_helper.rb
CHANGED
@@ -8,6 +8,7 @@ module MongodbLogger::SpecHelper
|
|
8
8
|
DEFAULT_CONFIG_WITH_AUTH = "database_with_auth.yml"
|
9
9
|
DEFAULT_CONFIG_CAPSIZE = "database_with_capsize.yml"
|
10
10
|
DEFAULT_CONFIG_WITH_URL = "database_with_url.yml"
|
11
|
+
DEFAULT_CONFIG_WITH_SSL = "database_with_ssl.yml"
|
11
12
|
DEFAULT_CONFIG_WITH_COLLECTION = "database_with_collection.yml"
|
12
13
|
DEFAULT_CONFIG_WITH_NO_FILE_LOGGING = "database_no_file_logging.yml"
|
13
14
|
REPLICA_SET_CONFIG = "database_replica_set.yml"
|
data/spec/utils/migrate_spec.rb
CHANGED
@@ -19,7 +19,7 @@ describe MongodbLogger::Utils::Migrate do
|
|
19
19
|
should_have_default_capsize
|
20
20
|
|
21
21
|
it 'changed after migration' do
|
22
|
-
MongodbLogger::Utils::Migrate.new
|
22
|
+
MongodbLogger::Utils::Migrate.new.run
|
23
23
|
@mongodb_logger = MongodbLogger::Logger.new
|
24
24
|
@mongo_adapter = @mongodb_logger.mongo_adapter
|
25
25
|
@mongo_adapter.collection_stats[:storageSize].should >= 50.megabyte
|
data/tasks/mongodb_logger.rake
CHANGED
@@ -4,7 +4,7 @@ require 'mongodb_logger/utils/migrate'
|
|
4
4
|
namespace :mongodb_logger do
|
5
5
|
desc 'copy data from mongodb collection to another'
|
6
6
|
task :migrate => :environment do |t, args|
|
7
|
-
MongodbLogger::Utils::Migrate.new
|
7
|
+
MongodbLogger::Utils::Migrate.new.run
|
8
8
|
puts "Operation finished"
|
9
9
|
end
|
10
10
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongodb_logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-04-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -112,17 +112,17 @@ dependencies:
|
|
112
112
|
requirement: !ruby/object:Gem::Requirement
|
113
113
|
none: false
|
114
114
|
requirements:
|
115
|
-
- - '
|
115
|
+
- - '='
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
117
|
+
version: 2.0.3
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
none: false
|
122
122
|
requirements:
|
123
|
-
- - '
|
123
|
+
- - '='
|
124
124
|
- !ruby/object:Gem::Version
|
125
|
-
version:
|
125
|
+
version: 2.0.3
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
127
|
name: coffee-script
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
@@ -390,7 +390,7 @@ extra_rdoc_files:
|
|
390
390
|
- README.md
|
391
391
|
files:
|
392
392
|
- .gitignore
|
393
|
-
- .
|
393
|
+
- .ruby-version
|
394
394
|
- .travis.yml
|
395
395
|
- Appraisals
|
396
396
|
- CHANGELOG.md
|
@@ -488,6 +488,8 @@ files:
|
|
488
488
|
- lib/mongodb_logger/server/model/base.rb
|
489
489
|
- lib/mongodb_logger/server/model/filter.rb
|
490
490
|
- lib/mongodb_logger/server/mustache/logs/info.rb
|
491
|
+
- lib/mongodb_logger/server/routes/analytic.rb
|
492
|
+
- lib/mongodb_logger/server/routes/logs.rb
|
491
493
|
- lib/mongodb_logger/server/templates/logs/info.mustache
|
492
494
|
- lib/mongodb_logger/server/views/analytics.erb
|
493
495
|
- lib/mongodb_logger/server/views/error.erb
|
@@ -503,6 +505,7 @@ files:
|
|
503
505
|
- lib/mongodb_logger/server/views/shared/layout/_mustache.erb
|
504
506
|
- lib/mongodb_logger/server/views/show_log.erb
|
505
507
|
- lib/mongodb_logger/server_config.rb
|
508
|
+
- lib/mongodb_logger/tagged_logger.rb
|
506
509
|
- lib/mongodb_logger/utils/migrate.rb
|
507
510
|
- lib/mongodb_logger/utils/progressbar.rb
|
508
511
|
- lib/mongodb_logger/version.rb
|
@@ -513,6 +516,7 @@ files:
|
|
513
516
|
- spec/factories/config/database_with_auth.yml
|
514
517
|
- spec/factories/config/database_with_capsize.yml
|
515
518
|
- spec/factories/config/database_with_collection.yml
|
519
|
+
- spec/factories/config/database_with_ssl.yml
|
516
520
|
- spec/factories/config/database_with_url.yml
|
517
521
|
- spec/factories/config/mongodb_logger.yml
|
518
522
|
- spec/factories/config/mongoid.yml
|
@@ -546,7 +550,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
546
550
|
version: '0'
|
547
551
|
segments:
|
548
552
|
- 0
|
549
|
-
hash:
|
553
|
+
hash: -1758663782148875802
|
550
554
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
551
555
|
none: false
|
552
556
|
requirements:
|
@@ -555,7 +559,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
555
559
|
version: '0'
|
556
560
|
segments:
|
557
561
|
- 0
|
558
|
-
hash:
|
562
|
+
hash: -1758663782148875802
|
559
563
|
requirements: []
|
560
564
|
rubyforge_project: mongodb_logger
|
561
565
|
rubygems_version: 1.8.25
|
@@ -577,6 +581,7 @@ test_files:
|
|
577
581
|
- spec/factories/config/database_with_auth.yml
|
578
582
|
- spec/factories/config/database_with_capsize.yml
|
579
583
|
- spec/factories/config/database_with_collection.yml
|
584
|
+
- spec/factories/config/database_with_ssl.yml
|
580
585
|
- spec/factories/config/database_with_url.yml
|
581
586
|
- spec/factories/config/mongodb_logger.yml
|
582
587
|
- spec/factories/config/mongoid.yml
|
data/.rvmrc
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
rvm ruby-2.0.0-p0@mongodb_logger_gems --create
|