mongodb_logger 0.6.2 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.ruby-version +1 -1
  4. data/.travis.yml +1 -8
  5. data/Appraisals +6 -4
  6. data/CHANGELOG.md +11 -0
  7. data/README.md +2 -2
  8. data/Rakefile +2 -10
  9. data/app/assets/javascripts/logs.js.coffee +24 -40
  10. data/app/assets/stylesheets/library.css.erb +6 -6
  11. data/config.ru +2 -2
  12. data/features/mongodb_logger_web.feature +8 -9
  13. data/features/step_definitions/mongodb_logger_web_steps.rb +10 -14
  14. data/gemfiles/rails31.gemfile +0 -1
  15. data/gemfiles/rails32.gemfile +0 -1
  16. data/gemfiles/rails40.gemfile +1 -2
  17. data/gemfiles/rails41.gemfile +8 -0
  18. data/lib/mongodb_logger/adapters/base.rb +1 -1
  19. data/lib/mongodb_logger/adapters/mongo.rb +3 -23
  20. data/lib/mongodb_logger/adapters/moped.rb +4 -25
  21. data/lib/mongodb_logger/initializer_mixin.rb +2 -3
  22. data/lib/mongodb_logger/logger.rb +122 -103
  23. data/lib/mongodb_logger/rack_middleware.rb +28 -4
  24. data/lib/mongodb_logger/railtie.rb +3 -1
  25. data/lib/mongodb_logger/server/routes/logs.rb +0 -10
  26. data/lib/mongodb_logger/server/views/overview.erb +20 -20
  27. data/lib/mongodb_logger/server/views/shared/_filter_panel.erb +12 -0
  28. data/lib/mongodb_logger/server_config.rb +4 -0
  29. data/lib/mongodb_logger/version.rb +1 -1
  30. data/mongodb_logger.gemspec +19 -24
  31. data/spec/mongodb_logger_spec.rb +38 -37
  32. data/spec/rails_spec/controllers/tests_controller_spec_rails.rb +25 -25
  33. data/spec/spec_helper.rb +6 -3
  34. data/spec/support/mongodb_logger_helper.rb +1 -1
  35. data/spec/support/mongodb_logger_macros.rb +4 -4
  36. data/spec/utils/migrate_spec.rb +2 -2
  37. data/tasks/mongodb_logger.rake +1 -1
  38. metadata +86 -164
  39. data/lib/mongodb_logger/server/views/shared/_tail_panel.erb +0 -13
  40. data/spec/javascripts/MongodbLoggerMainSpec.js +0 -13
  41. data/spec/javascripts/helpers/SpecHelper.js +0 -3
  42. data/spec/javascripts/support/jasmine.yml +0 -73
  43. data/spec/javascripts/support/jasmine_config.rb +0 -23
  44. data/spec/javascripts/support/jasmine_runner.rb +0 -32
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8ae987b579d29c9e088ea907aa2679494a1df53c
4
- data.tar.gz: a63a152e8ccf5ee8711bfcdfa199b95c9d59ad4c
3
+ metadata.gz: 48c3b365b540c0fdf70f0e4526fb83bd7730a85a
4
+ data.tar.gz: 3bbb2a8c14841e2adefa225549b959fd52914105
5
5
  SHA512:
6
- metadata.gz: b165d24c972e92d8f9924c979b2ca58d888bfd5f23ea229b60f1c2007df80f959e872eb51d518e210a1f577d60f05ac59e2ed5191254100644698df46a5e2126
7
- data.tar.gz: 66224465afd039b229111975c3199c79536df085dd0a56bc94e9835f08363448425c4dadb3e7d29c31e838119f6598e253e5b7ebc5a3a376260227aeed3fee54
6
+ metadata.gz: 9760b107a220bb5ddf047ba3e811173fc2775aaf7c6cb8966914ba7a3f202fac05326ffe9427efef78c93e42ab99a2f8004fc4923bdd7d0924556d6c87d3f610
7
+ data.tar.gz: e961c5158423d113e0b09b2d099bf67a8e67d969a0235cf65b587608eb54753d4fbc5727cd1b6cbfbd3043d64609b34bebd0a79d42de1214342760636a1b7c76
data/.gitignore CHANGED
@@ -2,6 +2,7 @@
2
2
  *.rbc
3
3
  .bundle
4
4
  .config
5
+ .idea
5
6
  .yardoc
6
7
  .project
7
8
  *.log
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.0.0
1
+ 2.1.1
data/.travis.yml CHANGED
@@ -2,7 +2,6 @@ language: ruby
2
2
  before_install:
3
3
  - "export DISPLAY=:99.0"
4
4
  - "sh -e /etc/init.d/xvfb start"
5
- - gem install bundler --pre
6
5
  before_script:
7
6
  - bundle exec rake appraisal:install
8
7
  services:
@@ -10,16 +9,10 @@ services:
10
9
  rvm:
11
10
  - 1.9.3
12
11
  - 2.0.0
13
- - jruby-19mode
14
- - ruby-head
15
- - jruby-head
12
+ - 2.1.0
16
13
  notifications:
17
14
  email: false
18
15
  branches:
19
16
  only:
20
17
  - master
21
18
  - development
22
- matrix:
23
- allow_failures:
24
- - rvm: ruby-head
25
- - rvm: jruby-head
data/Appraisals CHANGED
@@ -1,15 +1,17 @@
1
1
  appraise "rails31" do
2
2
  gem "rails", "~> 3.1.12"
3
- gem "mongodb_logger", :path => "../"
4
3
  end
5
4
 
6
5
  appraise "rails32" do
7
6
  gem "rails", "~> 3.2.14"
8
- gem "mongodb_logger", :path => "../"
9
7
  end
10
8
 
11
9
  appraise "rails40" do
12
- gem "rails", "4.0.0"
10
+ gem "rails", "~> 4.0.2"
13
11
  gem "minitest", "~> 4.0"
14
- gem "mongodb_logger", :path => "../"
12
+ end
13
+
14
+ appraise "rails41" do
15
+ gem "rails", "4.1.0.rc1"
16
+ gem "minitest", ">= 4.0"
15
17
  end
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  ## master
2
2
 
3
+
4
+ ## 0.6.3
5
+
6
+ * Allows a user to override the request_ip method (#56)
7
+ * Better support Sinatra apps (#60)
8
+ * Support moped 2.0.0.beta8
9
+ * Support Rails 4.1.0.rc1
10
+ * Removed unused actionpack
11
+
12
+ ## 0.6.2
13
+
3
14
  * Disable gem by option disable = false.
4
15
 
5
16
  ## 0.6.1
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
  [![Build Status](https://travis-ci.org/le0pard/mongodb_logger.png)](https://travis-ci.org/le0pard/mongodb_logger)
3
3
  [![Code Climate](https://codeclimate.com/github/le0pard/mongodb_logger.png)](https://codeclimate.com/github/le0pard/mongodb_logger)
4
4
 
5
- MongodbLogger is a alternative logger for Rails, which log all requests of you application into MongoDB database.
5
+ MongodbLogger is a alternative logger for Rails or Rack based app, which log all requests of you application into MongoDB database.
6
6
  It:
7
7
 
8
8
  * simple to integrate into existing Rails application;
@@ -42,7 +42,7 @@ Doesn't support the Rails version below 3.
42
42
  mkdir vendor/plugins/rails_log_stdout
43
43
  touch vendor/plugins/rails_log_stdout/.gitkeep
44
44
 
45
- For Rails 4 just remove from Gemfile "rails_12factor" rubygem.
45
+ For Rails 4 just remove from Gemfile "rails_12factor" gem.
46
46
 
47
47
  1. Add MongodbLogger settings to database.yml for each environment in which you want to use the MongodbLogger. The MongodbLogger will also
48
48
  look for a separate mongodb\_logger.yml or mongoid.yml (if you are using mongoid) before looking in database.yml.
data/Rakefile CHANGED
@@ -2,7 +2,8 @@
2
2
  require 'rubygems'
3
3
  require 'bundler'
4
4
 
5
- Bundler.require
5
+ Bundler.require(:default)
6
+
6
7
  require 'rake'
7
8
  require 'rake/testtask'
8
9
  require 'bundler/gem_tasks'
@@ -69,12 +70,3 @@ Cucumber::Rake::Task.new(:cucumber) do |t|
69
70
  t.fork = true
70
71
  t.cucumber_opts = cucumber_opts
71
72
  end
72
-
73
- begin
74
- require 'jasmine'
75
- load 'jasmine/tasks/jasmine.rake'
76
- rescue LoadError
77
- task :jasmine do
78
- abort "Jasmine is not available. In order to run jasmine, you must: (sudo) gem install jasmine"
79
- end
80
- end
@@ -12,15 +12,10 @@ root.MongodbLoggerMain =
12
12
  $(document).ajaxStart => $('#ajaxLoader').show()
13
13
  $(document).ajaxStop => $('#ajaxLoader').hide()
14
14
  # tail logs buttons
15
- $(document).on 'click', '#tailLogsLink', (event) =>
16
- event.preventDefault()
17
- MongodbLoggerMain.tailLogsUrl = $(event.currentTarget).data('url')
18
- $('#tailLogsBlock').addClass('started')
19
- MongodbLoggerMain.tailLogs(null)
20
- $(document).on 'click', '#tailLogsStopLink', (event) =>
21
- event.preventDefault()
22
- MongodbLoggerMain.tailLogStarted = false
23
- $('#tailLogsBlock').removeClass('started')
15
+ $(document).on 'click', '#filterLogsLink', (event) =>
16
+ @showFilters(event)
17
+ $(document).on 'click', '#filterLogsStopLink', (event) =>
18
+ @hideFilters(event)
24
19
  # log info click
25
20
  $(document).on 'click', '.log_info', (event) =>
26
21
  event.preventDefault()
@@ -30,9 +25,7 @@ root.MongodbLoggerMain =
30
25
  $('#logInfo').html(MustacheTemplates["logs/info"]({ log: element.data('info') }))
31
26
  # filter tougle
32
27
  $(document).on 'click', 'div.filter_toggle', (event) =>
33
- event.preventDefault()
34
- $('div.filter').slideToggle()
35
- $('div.filter_toggle span.arrow-down').toggleClass('rotate')
28
+ @toggleFilters(event)
36
29
  # additional filters
37
30
  $(document).on 'click', '#addMoreFilter', (event) =>
38
31
  event.preventDefault()
@@ -90,8 +83,23 @@ root.MongodbLoggerMain =
90
83
  when 40 # down
91
84
  MongodbLoggerMain.moveByLogs('down')
92
85
  # init pjax
93
- this.initPjax()
94
- this.initOnPages()
86
+ @initPjax()
87
+ @initOnPages()
88
+ showFilters: (e) ->
89
+ e.preventDefault()
90
+ $('div.filter').slideDown()
91
+ $('div.filter_toggle span.arrow-down').addClass('rotate')
92
+ $('#filterLogsBlock').addClass('started')
93
+ hideFilters: (e) ->
94
+ e.preventDefault()
95
+ $('div.filter').slideUp()
96
+ $('div.filter_toggle span.arrow-down').removeClass('rotate')
97
+ $('#filterLogsBlock').removeClass('started')
98
+ toggleFilters: (e) ->
99
+ if $('div.filter_toggle span.arrow-down').hasClass('rotate')
100
+ @hideFilters(e)
101
+ else
102
+ @showFilters(e)
95
103
  initPjax: ->
96
104
  # pjax
97
105
  $(document).pjax('a[data-pjax]', '#mainPjax')
@@ -124,29 +132,6 @@ root.MongodbLoggerMain =
124
132
  else
125
133
  $("#logInfo").stop().animate
126
134
  marginTop: 0
127
- # tail logs function
128
- tailLogs: (logLastId = null) ->
129
- url = MongodbLoggerMain.tailLogsUrl
130
- if logLastId? and logLastId.length
131
- url = "#{MongodbLoggerMain.tailLogsUrl}/#{logLastId}"
132
- else
133
- MongodbLoggerMain.tailLogStarted = true
134
- return false unless MongodbLoggerMain.tailLogStarted
135
- $.ajax
136
- url: url
137
- dataType: "json"
138
- success: (data) ->
139
- if data.time
140
- $('#tailLogsTime').text(data.time)
141
- if data.log_last_id?
142
- logLastId = data.log_last_id
143
- if data.content? && data.content.length > 0
144
- elements = $(data.content)
145
- elements.addClass('newlog')
146
- $('#logsList tr:first').after(elements).effect("highlight", {}, 1000)
147
- if data.collection_stats && $("#collection_stats").length > 0
148
- $("#collection_stats").html(data.collection_stats)
149
- setTimeout((-> MongodbLoggerMain.tailLogs(logLastId)), 2000) if MongodbLoggerMain.tailLogStarted
150
135
  # move using keys by logs
151
136
  moveByLogs: (direction) ->
152
137
  if $('#logsList').length and $('#logsList').find('tr.current').length
@@ -189,6 +174,5 @@ root.MongodbLoggerMain =
189
174
  elemTop = $(elem).offset().top
190
175
  elemBottom = elemTop + $(elem).height()
191
176
  return ((docViewTop < elemTop) && (docViewBottom > elemBottom))
192
-
193
- $ ->
194
- MongodbLoggerMain.init()
177
+ # init
178
+ $ -> MongodbLoggerMain.init()
@@ -144,7 +144,7 @@ code {
144
144
  background: -ms-linear-gradient(top, rgba(238,238,238,1) 0%,rgba(211,211,211,1) 100%);
145
145
  background: linear-gradient(top, rgba(238,238,238,1) 0%,rgba(211,211,211,1) 100%);
146
146
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#eeeeee', endColorstr='#d3d3d3',GradientType=0 );
147
-
147
+
148
148
  }
149
149
 
150
150
  .logs-time {
@@ -162,11 +162,11 @@ code {
162
162
  }
163
163
 
164
164
 
165
- #tailLogsBlock.started .info, #tailLogsBlock .initial {
165
+ #filterLogsBlock.started .info, #filterLogsBlock .initial {
166
166
  display: inline-block;
167
167
  }
168
168
 
169
- #tailLogsBlock .info, #tailLogsBlock.started .initial {
169
+ #filterLogsBlock .info, #filterLogsBlock.started .initial {
170
170
  display: none;
171
171
  }
172
172
 
@@ -204,7 +204,7 @@ li.message_tab {
204
204
  padding: 0 20px;
205
205
  height: 30px;
206
206
  line-height: 30px;
207
- font-size: 14px;
207
+ font-size: 14px;
208
208
  border-right: 1px solid #bbb;
209
209
  border-top: 0;
210
210
  color: #333;
@@ -219,7 +219,7 @@ li.message_tab {
219
219
  background: -ms-linear-gradient(top, rgba(255,255,255,0.62) 0%,rgba(23,146,212,0.5) 100%);
220
220
  background: linear-gradient(top, rgba(255,255,255,0.62) 0%,rgba(23,146,212,0.5) 100%);
221
221
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#9effffff', endColorstr='#801792d4',GradientType=0 );
222
-
222
+
223
223
  }
224
224
 
225
225
  .message_tabs li.active {
@@ -285,7 +285,7 @@ a[target="_blank"] {
285
285
  background: -ms-linear-gradient(top, rgba(191,210,85,1) 0%,rgba(142,185,42,1) 50%,rgba(114,170,0,1) 51%,rgba(158,203,45,1) 100%);
286
286
  background: linear-gradient(top, rgba(191,210,85,1) 0%,rgba(142,185,42,1) 50%,rgba(114,170,0,1) 51%,rgba(158,203,45,1) 100%);
287
287
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#bfd255', endColorstr='#9ecb2d',GradientType=0 );
288
-
288
+
289
289
  }
290
290
 
291
291
  .size {
data/config.ru CHANGED
@@ -6,10 +6,10 @@ require 'mongodb_logger/server'
6
6
 
7
7
  # Set the MONGODBLOGGERCONFIG env variable
8
8
  # config file you want loaded on boot.
9
- if ENV['MONGODBLOGGERCONFIG'] && ::File.exists?(::File.expand_path(ENV['MONGODBLOGGERCONFIG']))
9
+ if ENV['MONGODBLOGGERCONFIG'] && ::File.file?(::File.expand_path(ENV['MONGODBLOGGERCONFIG']))
10
10
  MongodbLogger::ServerConfig.set_config(::File.expand_path(ENV['MONGODBLOGGERCONFIG']))
11
11
  use Rack::ShowExceptions
12
-
12
+
13
13
  map '/assets' do
14
14
  run MongodbLogger::Assets.instance
15
15
  end
@@ -1,14 +1,13 @@
1
1
  Feature: Install MongodbLogger Web and test it
2
-
2
+
3
3
  Scenario: Main page
4
4
  Given homepage
5
5
  Then I should see text that no logs in system
6
-
7
- Scenario: Tail logs button
6
+
7
+ Scenario: Filter logs button
8
8
  Given homepage
9
- And I should see start tail button
10
- When I click on start tail button
11
- Then I should see stop tails button
12
- And box with time of last log tail
13
- When I click on stop tail button
14
- Then I should see start tail button
9
+ And I should see show filter button
10
+ When I click on show filter button
11
+ Then I should see hide filter button
12
+ When I click on hide filter button
13
+ Then I should see show filter button
@@ -26,25 +26,21 @@ Then /^I should see text that no logs in system$/ do
26
26
  page.has_selector?('div', text: 'No logs found, try to filter out the other parameters', visible: true)
27
27
  end
28
28
 
29
- Given /^I should see start tail button$/ do
30
- page.has_link?('tailLogsLink', visible: true)
31
- page.has_link?('tailLogsStopLink', visible: false)
29
+ Given /^I should see show filter button$/ do
30
+ page.has_link?('filterLogsLink', visible: true)
31
+ page.has_link?('filterLogsStopLink', visible: false)
32
32
  end
33
33
 
34
- When /^I click on start tail button$/ do
35
- click_link('tailLogsLink')
34
+ When /^I click on show filter button$/ do
35
+ click_link('filterLogsLink')
36
36
  end
37
37
 
38
- Then /^I should see stop tails button$/ do
39
- page.has_link?('tailLogsLink', visible: false)
40
- page.has_link?('tailLogsStopLink', visible: true)
38
+ Then /^I should see hide filter button$/ do
39
+ page.has_link?('filterLogsLink', visible: false)
40
+ page.has_link?('filterLogsStopLink', visible: true)
41
41
  end
42
42
 
43
- Then /^box with time of last log tail$/ do
44
- page.has_selector?('span#tailLogsTime', visible: true)
45
- end
46
-
47
- When /^I click on stop tail button$/ do
48
- click_link('tailLogsStopLink')
43
+ When /^I click on hide filter button$/ do
44
+ click_link('filterLogsStopLink')
49
45
  end
50
46
 
@@ -3,6 +3,5 @@
3
3
  source "http://rubygems.org"
4
4
 
5
5
  gem "rails", "~> 3.1.12"
6
- gem "mongodb_logger", :path=>"../"
7
6
 
8
7
  gemspec :path=>"../"
@@ -3,6 +3,5 @@
3
3
  source "http://rubygems.org"
4
4
 
5
5
  gem "rails", "~> 3.2.14"
6
- gem "mongodb_logger", :path=>"../"
7
6
 
8
7
  gemspec :path=>"../"
@@ -2,8 +2,7 @@
2
2
 
3
3
  source "http://rubygems.org"
4
4
 
5
- gem "rails", "4.0.0"
5
+ gem "rails", "~> 4.0.2"
6
6
  gem "minitest", "~> 4.0"
7
- gem "mongodb_logger", :path=>"../"
8
7
 
9
8
  gemspec :path=>"../"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "rails", "4.1.0.rc1"
6
+ gem "minitest", ">= 4.0"
7
+
8
+ gemspec :path=>"../"
@@ -19,7 +19,7 @@ module MongodbLogger
19
19
  end
20
20
 
21
21
  def rename_collection_command(admin_session, to, drop_target = false)
22
- admin_session.command({ renameCollection: "#{@configuration[:database]}.#{collection_name}", to: "#{@configuration[:database]}.#{to}", dropTarget: drop_target })
22
+ admin_session.command(renameCollection: "#{@configuration[:database]}.#{collection_name}", to: "#{@configuration[:database]}.#{to}", dropTarget: drop_target)
23
23
  end
24
24
 
25
25
  def reset_collection
@@ -26,6 +26,7 @@ module MongodbLogger
26
26
  end
27
27
 
28
28
  def insert_log_record(record, options = {})
29
+ record[:_id] = ::BSON::ObjectId.new
29
30
  @collection.insert(record, options[:write_options])
30
31
  end
31
32
 
@@ -39,32 +40,11 @@ module MongodbLogger
39
40
 
40
41
  # filter
41
42
  def filter_by_conditions(filter)
42
- @collection.find(filter.get_mongo_conditions).sort('$natural', -1).limit(filter.get_mongo_limit)
43
+ @collection.find(filter.get_mongo_conditions).limit(filter.get_mongo_limit).sort('$natural', -1)
43
44
  end
44
45
 
45
46
  def find_by_id(id)
46
- @collection.find_one(::BSON::ObjectId(id))
47
- end
48
-
49
- def tail_log_from_params(params = {})
50
- logs = []
51
- last_id = nil
52
- if params[:log_last_id] && !params[:log_last_id].blank?
53
- log_last_id = params[:log_last_id]
54
- @collection.find({'_id' => { '$gt' => ::BSON::ObjectId(log_last_id) }}).sort('$natural', -1).each do |log|
55
- logs << log
56
- log_last_id = log["_id"].to_s
57
- end
58
- logs.reverse!
59
- else
60
- log = @collection.find_one({}, { sort: ['$natural', -1] })
61
- log_last_id = log["_id"].to_s unless log.blank?
62
- end
63
- {
64
- log_last_id: log_last_id,
65
- time: Time.now.strftime("%F %T"),
66
- logs: logs
67
- }
47
+ @collection.find_one(::BSON::ObjectId.from_string(id))
68
48
  end
69
49
 
70
50
  def calculate_mapreduce(map, reduce, params = {})
@@ -26,8 +26,8 @@ module MongodbLogger
26
26
  end
27
27
 
28
28
  def insert_log_record(record, options = {})
29
- record[:_id] = ::Moped::BSON::ObjectId.new
30
- @connection.with(safe: options[:write_options])[collection_name].insert(record)
29
+ record[:_id] = ::BSON::ObjectId.new
30
+ @connection.with(write: options[:write_options])[collection_name].insert(record)
31
31
  end
32
32
 
33
33
  def collection_stats
@@ -42,32 +42,11 @@ module MongodbLogger
42
42
 
43
43
  # filter
44
44
  def filter_by_conditions(filter)
45
- @collection.find(filter.get_mongo_conditions).sort('$natural' => -1).limit(filter.get_mongo_limit)
45
+ @collection.find(filter.get_mongo_conditions).limit(filter.get_mongo_limit).sort('$natural' => -1)
46
46
  end
47
47
 
48
48
  def find_by_id(id)
49
- @collection.find("_id" => ::Moped::BSON::ObjectId.from_string(id)).first
50
- end
51
-
52
- def tail_log_from_params(params = {})
53
- logs = []
54
- last_id = nil
55
- if params[:log_last_id] && !params[:log_last_id].blank?
56
- log_last_id = params[:log_last_id]
57
- @collection.find({'_id' => { '$gt' => ::Moped::BSON::ObjectId.from_string(log_last_id) }}).sort('$natural' => -1).each do |log|
58
- logs << log
59
- log_last_id = log["_id"].to_s
60
- end
61
- logs.reverse!
62
- else
63
- log = @collection.find.sort('$natural' => -1).first
64
- log_last_id = log["_id"].to_s unless log.blank?
65
- end
66
- {
67
- log_last_id: log_last_id,
68
- time: Time.now.strftime("%F %T"),
69
- logs: logs
70
- }
49
+ @collection.find("_id" => ::BSON::ObjectId.from_string(id)).first
71
50
  end
72
51
 
73
52
  def calculate_mapreduce(map, reduce, params = {})