mongodb_logger 0.3.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. data/.rvmrc +1 -1
  2. data/.travis.yml +13 -7
  3. data/Gemfile +1 -7
  4. data/README.md +128 -117
  5. data/Rakefile +11 -40
  6. data/SUPPORTED_RAILS_VERSIONS +3 -1
  7. data/app/assets/javascripts/analytics.js.coffee +66 -0
  8. data/app/assets/javascripts/logs.js.coffee +107 -164
  9. data/app/assets/javascripts/mongodb_logger.js +11 -2
  10. data/app/assets/javascripts/vendors/jquery-1.8.3.min.js +2 -0
  11. data/app/assets/javascripts/vendors/jquery-ui-1.9.2.min.js +6 -0
  12. data/app/assets/javascripts/vendors/jquery.pjax.min.js +13 -6
  13. data/app/assets/javascripts/vendors/rickshaw/d3.layout.min.js +1 -0
  14. data/app/assets/javascripts/vendors/rickshaw/d3.min.js +2 -0
  15. data/app/assets/javascripts/vendors/rickshaw/rickshaw.js +2637 -0
  16. data/app/assets/stylesheets/humanity/{jquery-ui-1.8.16.custom.css → jquery-ui-1.9.2.custom.css} +0 -0
  17. data/app/assets/stylesheets/layout.css +1 -1
  18. data/app/assets/stylesheets/library.css.erb +2 -2
  19. data/app/assets/stylesheets/mongodb_logger.css +2 -1
  20. data/app/assets/stylesheets/rickshaw/rickshaw.css +307 -0
  21. data/bin/mongodb_logger_web +1 -2
  22. data/config.ru +8 -1
  23. data/examples/server_config.yml +1 -2
  24. data/features/mongodb_logger_web.feature +1 -1
  25. data/features/step_definitions/mongodb_logger_web_steps.rb +18 -12
  26. data/lib/mongodb_logger.rb +6 -2
  27. data/lib/mongodb_logger/adapters.rb +3 -0
  28. data/lib/mongodb_logger/adapters/base.rb +45 -0
  29. data/lib/mongodb_logger/adapters/mongo.rb +91 -0
  30. data/lib/mongodb_logger/adapters/moped.rb +95 -0
  31. data/lib/mongodb_logger/logger.rb +39 -71
  32. data/lib/mongodb_logger/replica_set_helper.rb +11 -2
  33. data/lib/mongodb_logger/server.rb +15 -36
  34. data/lib/mongodb_logger/server/model/analytic.rb +54 -37
  35. data/lib/mongodb_logger/server/view_helpers.rb +5 -1
  36. data/lib/mongodb_logger/server/views/analytics.erb +8 -7
  37. data/lib/mongodb_logger/server/views/layout.erb +4 -11
  38. data/lib/mongodb_logger/server/views/overview.erb +6 -6
  39. data/lib/mongodb_logger/server/views/shared/_collection_stats.erb +4 -4
  40. data/lib/mongodb_logger/server/views/shared/_dynamic_filter.erb +1 -1
  41. data/lib/mongodb_logger/server/views/shared/_log_info.erb +1 -1
  42. data/lib/mongodb_logger/server/views/shared/_tabs.erb +2 -2
  43. data/lib/mongodb_logger/server/views/shared/_tail_panel.erb +4 -4
  44. data/lib/mongodb_logger/server/views/shared/_top_panel.erb +1 -1
  45. data/lib/mongodb_logger/server/views/show_log.erb +11 -1
  46. data/lib/mongodb_logger/server_config.rb +17 -66
  47. data/lib/mongodb_logger/version.rb +1 -1
  48. data/mongodb_logger.gemspec +19 -20
  49. data/spec/javascripts/MongodbLoggerMainSpec.js +2 -2
  50. data/spec/javascripts/support/jasmine.yml +5 -5
  51. data/test/Gemfile_tests +2 -1
  52. data/test/config/samples/database.yml +3 -1
  53. data/test/config/samples/database_no_file_logging.yml +3 -1
  54. data/test/shoulda_macros/log_macros.rb +1 -1
  55. data/test/test.sh +5 -5
  56. data/test/test_helper.rb +26 -18
  57. data/test/unit/mongodb_logger_test.rb +21 -20
  58. metadata +70 -88
  59. data/app/assets/javascripts/vendors/jquery-1.7.1.min.js +0 -4
  60. data/app/assets/javascripts/vendors/jquery-ui-1.8.16.min.js +0 -791
  61. data/mongodb_logger.java.gemspec +0 -43
@@ -164,7 +164,7 @@ body {
164
164
  color: #666;
165
165
  }
166
166
 
167
- #ajax_loader {
167
+ #ajaxLoader {
168
168
  display: none;
169
169
  position: absolute;
170
170
  top: 15px;
@@ -162,11 +162,11 @@ code {
162
162
  }
163
163
 
164
164
 
165
- #tail_logs_block.started .info, #tail_logs_block .initial {
165
+ #tailLogsBlock.started .info, #tailLogsBlock .initial {
166
166
  display: inline-block;
167
167
  }
168
168
 
169
- #tail_logs_block .info, #tail_logs_block.started .initial {
169
+ #tailLogsBlock .info, #tailLogsBlock.started .initial {
170
170
  display: none;
171
171
  }
172
172
 
@@ -11,6 +11,7 @@
11
11
  *= require "group-buttons.css.erb"
12
12
  *= require "group-forms.css"
13
13
  *= require "group-tables.css"
14
- *= require "humanity/jquery-ui-1.8.16.custom.css"
14
+ *= require "humanity/jquery-ui-1.9.2.custom.css"
15
15
  *= require "highlight/zenburn.css"
16
+ *= require "rickshaw/rickshaw.css"
16
17
  */
@@ -0,0 +1,307 @@
1
+ .rickshaw_graph .detail {
2
+ pointer-events: none;
3
+ position: absolute;
4
+ top: 0;
5
+ z-index: 2;
6
+ background: rgba(0, 0, 0, 0.1);
7
+ bottom: 0;
8
+ width: 1px;
9
+ transition: opacity 0.25s linear;
10
+ -moz-transition: opacity 0.25s linear;
11
+ -o-transition: opacity 0.25s linear;
12
+ -webkit-transition: opacity 0.25s linear;
13
+ }
14
+ .rickshaw_graph .detail.inactive {
15
+ opacity: 0;
16
+ }
17
+ .rickshaw_graph .detail .item.active {
18
+ opacity: 1;
19
+ }
20
+ .rickshaw_graph .detail .x_label {
21
+ font-family: Arial, sans-serif;
22
+ border-radius: 3px;
23
+ padding: 6px;
24
+ opacity: 0.5;
25
+ border: 1px solid #e0e0e0;
26
+ font-size: 12px;
27
+ position: absolute;
28
+ background: white;
29
+ white-space: nowrap;
30
+ }
31
+ .rickshaw_graph .detail .item {
32
+ position: absolute;
33
+ z-index: 2;
34
+ border-radius: 3px;
35
+ padding: 0.25em;
36
+ font-size: 12px;
37
+ font-family: Arial, sans-serif;
38
+ opacity: 0;
39
+ background: rgba(0, 0, 0, 0.4);
40
+ color: white;
41
+ border: 1px solid rgba(0, 0, 0, 0.4);
42
+ margin-left: 1em;
43
+ margin-top: -1em;
44
+ white-space: nowrap;
45
+ }
46
+ .rickshaw_graph .detail .item.active {
47
+ opacity: 1;
48
+ background: rgba(0, 0, 0, 0.8);
49
+ }
50
+ .rickshaw_graph .detail .item:before {
51
+ content: "\25c2";
52
+ position: absolute;
53
+ left: -0.5em;
54
+ color: rgba(0, 0, 0, 0.7);
55
+ width: 0;
56
+ }
57
+ .rickshaw_graph .detail .dot {
58
+ width: 4px;
59
+ height: 4px;
60
+ margin-left: -4px;
61
+ margin-top: -3px;
62
+ border-radius: 5px;
63
+ position: absolute;
64
+ box-shadow: 0 0 2px rgba(0, 0, 0, 0.6);
65
+ background: white;
66
+ border-width: 2px;
67
+ border-style: solid;
68
+ display: none;
69
+ background-clip: padding-box;
70
+ }
71
+ .rickshaw_graph .detail .dot.active {
72
+ display: block;
73
+ }
74
+ /* graph */
75
+
76
+ .rickshaw_graph {
77
+ position: relative;
78
+ }
79
+ .rickshaw_graph svg {
80
+ display: block;
81
+ overflow: hidden;
82
+ }
83
+
84
+ /* ticks */
85
+
86
+ .rickshaw_graph .x_tick {
87
+ position: absolute;
88
+ top: 0;
89
+ bottom: 0;
90
+ width: 0px;
91
+ border-left: 1px dotted rgba(0, 0, 0, 0.2);
92
+ pointer-events: none;
93
+ }
94
+ .rickshaw_graph .x_tick .title {
95
+ position: absolute;
96
+ font-size: 12px;
97
+ font-family: Arial, sans-serif;
98
+ opacity: 0.5;
99
+ white-space: nowrap;
100
+ margin-left: 3px;
101
+ bottom: 1px;
102
+ }
103
+
104
+ /* annotations */
105
+
106
+ .rickshaw_annotation_timeline {
107
+ height: 1px;
108
+ border-top: 1px solid #e0e0e0;
109
+ margin-top: 10px;
110
+ position: relative;
111
+ }
112
+ .rickshaw_annotation_timeline .annotation {
113
+ position: absolute;
114
+ height: 6px;
115
+ width: 6px;
116
+ margin-left: -2px;
117
+ top: -3px;
118
+ border-radius: 5px;
119
+ background-color: rgba(0, 0, 0, 0.25);
120
+ }
121
+ .rickshaw_graph .annotation_line {
122
+ position: absolute;
123
+ top: 0;
124
+ bottom: -6px;
125
+ width: 0px;
126
+ border-left: 2px solid rgba(0, 0, 0, 0.3);
127
+ display: none;
128
+ }
129
+ .rickshaw_graph .annotation_line.active {
130
+ display: block;
131
+ }
132
+
133
+ .rickshaw_graph .annotation_range {
134
+ background: rgba(0, 0, 0, 0.1);
135
+ display: none;
136
+ position: absolute;
137
+ top: 0;
138
+ bottom: -6px;
139
+ z-index: -10;
140
+ }
141
+ .rickshaw_graph .annotation_range.active {
142
+ display: block;
143
+ }
144
+ .rickshaw_graph .annotation_range.active.offscreen {
145
+ display: none;
146
+ }
147
+
148
+ .rickshaw_annotation_timeline .annotation .content {
149
+ background: white;
150
+ color: black;
151
+ opacity: 0.9;
152
+ padding: 5px 5px;
153
+ box-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
154
+ border-radius: 3px;
155
+ position: relative;
156
+ z-index: 20;
157
+ font-size: 12px;
158
+ padding: 6px 8px 8px;
159
+ top: 18px;
160
+ left: -11px;
161
+ width: 160px;
162
+ display: none;
163
+ cursor: pointer;
164
+ }
165
+ .rickshaw_annotation_timeline .annotation .content:before {
166
+ content: "\25b2";
167
+ position: absolute;
168
+ top: -11px;
169
+ color: white;
170
+ text-shadow: 0 -1px 1px rgba(0, 0, 0, 0.8);
171
+ }
172
+ .rickshaw_annotation_timeline .annotation.active,
173
+ .rickshaw_annotation_timeline .annotation:hover {
174
+ background-color: rgba(0, 0, 0, 0.8);
175
+ cursor: none;
176
+ }
177
+ .rickshaw_annotation_timeline .annotation .content:hover {
178
+ z-index: 50;
179
+ }
180
+ .rickshaw_annotation_timeline .annotation.active .content {
181
+ display: block;
182
+ }
183
+ .rickshaw_annotation_timeline .annotation:hover .content {
184
+ display: block;
185
+ z-index: 50;
186
+ }
187
+ .rickshaw_graph .y_axis {
188
+ fill: none;
189
+ }
190
+ .rickshaw_graph .y_ticks .tick {
191
+ stroke: rgba(0, 0, 0, 0.16);
192
+ stroke-width: 2px;
193
+ shape-rendering: crisp-edges;
194
+ pointer-events: none;
195
+ }
196
+ .rickshaw_graph .y_grid .tick {
197
+ z-index: -1;
198
+ stroke: rgba(0, 0, 0, 0.20);
199
+ stroke-width: 1px;
200
+ stroke-dasharray: 1 1;
201
+ }
202
+ .rickshaw_graph .y_grid path {
203
+ fill: none;
204
+ stroke: none;
205
+ }
206
+ .rickshaw_graph .y_ticks path {
207
+ fill: none;
208
+ stroke: #808080;
209
+ }
210
+ .rickshaw_graph .y_ticks text {
211
+ opacity: 0.5;
212
+ font-size: 12px;
213
+ pointer-events: none;
214
+ }
215
+ .rickshaw_graph .x_tick.glow .title,
216
+ .rickshaw_graph .y_ticks.glow text {
217
+ fill: black;
218
+ color: black;
219
+ text-shadow:
220
+ -1px 1px 0 rgba(255, 255, 255, 0.1),
221
+ 1px -1px 0 rgba(255, 255, 255, 0.1),
222
+ 1px 1px 0 rgba(255, 255, 255, 0.1),
223
+ 0px 1px 0 rgba(255, 255, 255, 0.1),
224
+ 0px -1px 0 rgba(255, 255, 255, 0.1),
225
+ 1px 0px 0 rgba(255, 255, 255, 0.1),
226
+ -1px 0px 0 rgba(255, 255, 255, 0.1),
227
+ -1px -1px 0 rgba(255, 255, 255, 0.1);
228
+ }
229
+ .rickshaw_graph .x_tick.inverse .title,
230
+ .rickshaw_graph .y_ticks.inverse text {
231
+ fill: white;
232
+ color: white;
233
+ text-shadow:
234
+ -1px 1px 0 rgba(0, 0, 0, 0.8),
235
+ 1px -1px 0 rgba(0, 0, 0, 0.8),
236
+ 1px 1px 0 rgba(0, 0, 0, 0.8),
237
+ 0px 1px 0 rgba(0, 0, 0, 0.8),
238
+ 0px -1px 0 rgba(0, 0, 0, 0.8),
239
+ 1px 0px 0 rgba(0, 0, 0, 0.8),
240
+ -1px 0px 0 rgba(0, 0, 0, 0.8),
241
+ -1px -1px 0 rgba(0, 0, 0, 0.8);
242
+ }
243
+ .rickshaw_legend {
244
+ font-family: Arial;
245
+ font-size: 12px;
246
+ color: white;
247
+ background: #404040;
248
+ display: inline-block;
249
+ padding: 12px 5px;
250
+ border-radius: 2px;
251
+ position: relative;
252
+ }
253
+ .rickshaw_legend:hover {
254
+ z-index: 10;
255
+ }
256
+ .rickshaw_legend .swatch {
257
+ width: 10px;
258
+ height: 10px;
259
+ border: 1px solid rgba(0, 0, 0, 0.2);
260
+ }
261
+ .rickshaw_legend .line {
262
+ clear: both;
263
+ line-height: 140%;
264
+ padding-right: 15px;
265
+ }
266
+ .rickshaw_legend .line .swatch {
267
+ display: inline-block;
268
+ margin-right: 3px;
269
+ border-radius: 2px;
270
+ }
271
+ .rickshaw_legend .label {
272
+ white-space: nowrap;
273
+ display: inline;
274
+ }
275
+ .rickshaw_legend .action:hover {
276
+ opacity: 0.6;
277
+ }
278
+ .rickshaw_legend .action {
279
+ margin-right: 0.2em;
280
+ font-size: 10px;
281
+ opacity: 0.2;
282
+ cursor: pointer;
283
+ font-size: 14px;
284
+ }
285
+ .rickshaw_legend .line.disabled {
286
+ opacity: 0.4;
287
+ }
288
+ .rickshaw_legend ul {
289
+ list-style-type: none;
290
+ margin: 0;
291
+ padding: 0;
292
+ margin: 2px;
293
+ cursor: pointer;
294
+ }
295
+ .rickshaw_legend li {
296
+ padding: 0 0 0 2px;
297
+ min-width: 80px;
298
+ white-space: nowrap;
299
+ }
300
+ .rickshaw_legend li:hover {
301
+ background: rgba(255, 255, 255, 0.08);
302
+ border-radius: 3px;
303
+ }
304
+ .rickshaw_legend li:active {
305
+ background: rgba(255, 255, 255, 0.2);
306
+ border-radius: 3px;
307
+ }
@@ -9,7 +9,6 @@ rescue LoadError
9
9
  end
10
10
  require 'mongodb_logger/server'
11
11
 
12
-
13
12
  Vegas::Runner.new(MongodbLogger::Server, 'mongodb_logger_web', {
14
13
  :before_run => lambda {|v|
15
14
  config_file = (ENV['MONGODBLOGGERCONFIG'] || v.args.first)
@@ -20,5 +19,5 @@ Vegas::Runner.new(MongodbLogger::Server, 'mongodb_logger_web', {
20
19
  end
21
20
  }
22
21
  }) do |runner, opts, app|
23
- #
22
+
24
23
  end
data/config.ru CHANGED
@@ -9,7 +9,14 @@ require 'mongodb_logger/server'
9
9
  if ENV['MONGODBLOGGERCONFIG'] && ::File.exists?(::File.expand_path(ENV['MONGODBLOGGERCONFIG']))
10
10
  MongodbLogger::ServerConfig.set_config(::File.expand_path(ENV['MONGODBLOGGERCONFIG']))
11
11
  use Rack::ShowExceptions
12
- run MongodbLogger::Server.new
12
+
13
+ map '/assets' do
14
+ run MongodbLogger::Assets.instance
15
+ end
16
+
17
+ map '/' do
18
+ run MongodbLogger::Server.new
19
+ end
13
20
  else
14
21
  raise "Please provide config file"
15
22
  exit 1
@@ -1,5 +1,4 @@
1
1
  database: monkey_logs_dev
2
2
  host: localhost
3
3
  port: 27017
4
- collection: development_log
5
- #collection: prod_imported
4
+ collection: development_log
@@ -4,7 +4,7 @@ Feature: Install MongodbLogger Web and test it
4
4
  Given homepage
5
5
  Then I should see text that no logs in system
6
6
 
7
- Scenario: Tail logs buttons
7
+ Scenario: Tail logs button
8
8
  Given homepage
9
9
  And I should see start tail button
10
10
  When I click on start tail button
@@ -1,16 +1,22 @@
1
1
  require 'active_support/core_ext/string/inflections'
2
2
  require 'mongodb_logger/server'
3
+ require 'capybara'
3
4
  require 'capybara/cucumber'
4
-
5
- include Capybara::DSL
5
+ require 'capybara/dsl'
6
6
 
7
7
  Before do
8
- MongodbLogger::ServerConfig.set_config_for_testing(File.join(PROJECT_ROOT, 'test/config/samples/server_config.yml'))
9
- Capybara.app = MongodbLogger::Server
8
+ @mongo_adapter = MongodbLogger::ServerConfig.set_config(File.join(PROJECT_ROOT, 'test/config/samples/server_config.yml'))
9
+ @mongo_adapter.collection.drop
10
+ @mongo_adapter.create_collection
11
+ Capybara.default_selector = :css
12
+ Capybara.app = Rack::Builder.new do
13
+ map('/assets') { run MongodbLogger::Assets.instance }
14
+ map('/') { run MongodbLogger::Server.new }
15
+ end
10
16
  end
11
17
 
12
18
  After do
13
- MongodbLogger::ServerConfig.collection.drop
19
+ @mongo_adapter.collection.drop
14
20
  end
15
21
 
16
22
  Given /^homepage$/ do
@@ -22,24 +28,24 @@ Then /^I should see text that no logs in system$/ do
22
28
  end
23
29
 
24
30
  Given /^I should see start tail button$/ do
25
- page.has_link?('tail_logs_link', :visible => true)
26
- page.has_link?('tail_logs_stop_link', :visible => false)
31
+ page.has_link?('tailLogsLink', :visible => true)
32
+ page.has_link?('tailLogsStopLink', :visible => false)
27
33
  end
28
34
 
29
35
  When /^I click on start tail button$/ do
30
- click_link('tail_logs_link')
36
+ click_link('tailLogsLink')
31
37
  end
32
38
 
33
39
  Then /^I should see stop tails button$/ do
34
- page.has_link?('tail_logs_link', :visible => false)
35
- page.has_link?('tail_logs_stop_link', :visible => true)
40
+ page.has_link?('tailLogsLink', :visible => false)
41
+ page.has_link?('tailLogsStopLink', :visible => true)
36
42
  end
37
43
 
38
44
  Then /^box with time of last log tail$/ do
39
- page.has_selector?('span', :id => 'tail_logs_time', :visible => true)
45
+ page.has_selector?('span#tailLogsTime', :visible => true)
40
46
  end
41
47
 
42
48
  When /^I click on stop tail button$/ do
43
- click_link('tail_logs_stop_link')
49
+ click_link('tailLogsStopLink')
44
50
  end
45
51