mongodb_logger 0.2.6-jruby

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. data/.gitignore +20 -0
  2. data/.rvmrc +1 -0
  3. data/.travis.yml +19 -0
  4. data/CHANGELOG.md +30 -0
  5. data/Gemfile +10 -0
  6. data/LICENSE +22 -0
  7. data/README.md +207 -0
  8. data/Rakefile +169 -0
  9. data/SUPPORTED_RAILS_VERSIONS +17 -0
  10. data/TESTING.md +24 -0
  11. data/bin/mongodb_logger_web +24 -0
  12. data/config.ru +17 -0
  13. data/examples/server_config.yml +5 -0
  14. data/features/mongodb_logger_web.feature +14 -0
  15. data/features/rails.feature +12 -0
  16. data/features/step_definitions/mongodb_logger_web_steps.rb +45 -0
  17. data/features/step_definitions/rails_application_steps.rb +65 -0
  18. data/features/support/env.rb +15 -0
  19. data/features/support/rails.rb +98 -0
  20. data/features/support/terminal.rb +95 -0
  21. data/lib/mongodb_logger/initializer_mixin.rb +26 -0
  22. data/lib/mongodb_logger/logger.rb +239 -0
  23. data/lib/mongodb_logger/railtie.rb +12 -0
  24. data/lib/mongodb_logger/replica_set_helper.rb +19 -0
  25. data/lib/mongodb_logger/server/coffee/logs.coffee +250 -0
  26. data/lib/mongodb_logger/server/content_for.rb +58 -0
  27. data/lib/mongodb_logger/server/model/additional_filter.rb +104 -0
  28. data/lib/mongodb_logger/server/model/analytic.rb +82 -0
  29. data/lib/mongodb_logger/server/model/filter.rb +84 -0
  30. data/lib/mongodb_logger/server/partials.rb +24 -0
  31. data/lib/mongodb_logger/server/public/images/arrow-down.png +0 -0
  32. data/lib/mongodb_logger/server/public/images/arrow-up.png +0 -0
  33. data/lib/mongodb_logger/server/public/images/date.png +0 -0
  34. data/lib/mongodb_logger/server/public/images/external.png +0 -0
  35. data/lib/mongodb_logger/server/public/images/failure.png +0 -0
  36. data/lib/mongodb_logger/server/public/images/logo.png +0 -0
  37. data/lib/mongodb_logger/server/public/images/mongodb.png +0 -0
  38. data/lib/mongodb_logger/server/public/images/newlog.png +0 -0
  39. data/lib/mongodb_logger/server/public/images/play-icon.png +0 -0
  40. data/lib/mongodb_logger/server/public/images/spinner.gif +0 -0
  41. data/lib/mongodb_logger/server/public/images/spinner2.gif +0 -0
  42. data/lib/mongodb_logger/server/public/images/stop-icon.png +0 -0
  43. data/lib/mongodb_logger/server/public/images/success.png +0 -0
  44. data/lib/mongodb_logger/server/public/javascripts/logs.js +1 -0
  45. data/lib/mongodb_logger/server/public/javascripts/vendors/highlight.pack.js +1 -0
  46. data/lib/mongodb_logger/server/public/javascripts/vendors/jquery-1.7.1.min.js +4 -0
  47. data/lib/mongodb_logger/server/public/javascripts/vendors/jquery-ui-1.8.16.min.js +791 -0
  48. data/lib/mongodb_logger/server/public/javascripts/vendors/jquery.pjax.min.js +6 -0
  49. data/lib/mongodb_logger/server/public/stylesheets/all.css +12 -0
  50. data/lib/mongodb_logger/server/public/stylesheets/grids.css +18 -0
  51. data/lib/mongodb_logger/server/public/stylesheets/group-buttons.css +81 -0
  52. data/lib/mongodb_logger/server/public/stylesheets/group-forms.css +59 -0
  53. data/lib/mongodb_logger/server/public/stylesheets/group-headers.css +8 -0
  54. data/lib/mongodb_logger/server/public/stylesheets/group-tables.css +87 -0
  55. data/lib/mongodb_logger/server/public/stylesheets/highlight/zenburn.css +115 -0
  56. data/lib/mongodb_logger/server/public/stylesheets/humanity/images/ui-bg_flat_75_aaaaaa_40x100.png +0 -0
  57. data/lib/mongodb_logger/server/public/stylesheets/humanity/images/ui-bg_glass_100_f5f0e5_1x400.png +0 -0
  58. data/lib/mongodb_logger/server/public/stylesheets/humanity/images/ui-bg_glass_25_cb842e_1x400.png +0 -0
  59. data/lib/mongodb_logger/server/public/stylesheets/humanity/images/ui-bg_glass_70_ede4d4_1x400.png +0 -0
  60. data/lib/mongodb_logger/server/public/stylesheets/humanity/images/ui-bg_highlight-hard_100_f4f0ec_1x100.png +0 -0
  61. data/lib/mongodb_logger/server/public/stylesheets/humanity/images/ui-bg_highlight-hard_65_fee4bd_1x100.png +0 -0
  62. data/lib/mongodb_logger/server/public/stylesheets/humanity/images/ui-bg_highlight-hard_75_f5f5b5_1x100.png +0 -0
  63. data/lib/mongodb_logger/server/public/stylesheets/humanity/images/ui-bg_inset-soft_100_f4f0ec_1x100.png +0 -0
  64. data/lib/mongodb_logger/server/public/stylesheets/humanity/images/ui-icons_c47a23_256x240.png +0 -0
  65. data/lib/mongodb_logger/server/public/stylesheets/humanity/images/ui-icons_cb672b_256x240.png +0 -0
  66. data/lib/mongodb_logger/server/public/stylesheets/humanity/images/ui-icons_f08000_256x240.png +0 -0
  67. data/lib/mongodb_logger/server/public/stylesheets/humanity/images/ui-icons_f35f07_256x240.png +0 -0
  68. data/lib/mongodb_logger/server/public/stylesheets/humanity/images/ui-icons_ff7519_256x240.png +0 -0
  69. data/lib/mongodb_logger/server/public/stylesheets/humanity/images/ui-icons_ffffff_256x240.png +0 -0
  70. data/lib/mongodb_logger/server/public/stylesheets/humanity/jquery-ui-1.8.16.custom.css +568 -0
  71. data/lib/mongodb_logger/server/public/stylesheets/layout.css +205 -0
  72. data/lib/mongodb_logger/server/public/stylesheets/library.css +330 -0
  73. data/lib/mongodb_logger/server/public/stylesheets/reset.css +43 -0
  74. data/lib/mongodb_logger/server/public/stylesheets/spaces.css +42 -0
  75. data/lib/mongodb_logger/server/view_helpers.rb +113 -0
  76. data/lib/mongodb_logger/server/views/analytics.erb +61 -0
  77. data/lib/mongodb_logger/server/views/error.erb +2 -0
  78. data/lib/mongodb_logger/server/views/layout.erb +47 -0
  79. data/lib/mongodb_logger/server/views/overview.erb +119 -0
  80. data/lib/mongodb_logger/server/views/shared/_collection_stats.erb +14 -0
  81. data/lib/mongodb_logger/server/views/shared/_dynamic_filter.erb +34 -0
  82. data/lib/mongodb_logger/server/views/shared/_log.erb +8 -0
  83. data/lib/mongodb_logger/server/views/shared/_log_info.erb +27 -0
  84. data/lib/mongodb_logger/server/views/shared/_message_tabs.erb +15 -0
  85. data/lib/mongodb_logger/server/views/shared/_tabs.erb +4 -0
  86. data/lib/mongodb_logger/server/views/shared/_tail_panel.erb +13 -0
  87. data/lib/mongodb_logger/server/views/shared/_top_panel.erb +7 -0
  88. data/lib/mongodb_logger/server/views/show_log.erb +105 -0
  89. data/lib/mongodb_logger/server.rb +174 -0
  90. data/lib/mongodb_logger/server_config.rb +77 -0
  91. data/lib/mongodb_logger/version.rb +3 -0
  92. data/lib/mongodb_logger.rb +31 -0
  93. data/mongodb_logger.gemspec +44 -0
  94. data/mongodb_logger.java.gemspec +42 -0
  95. data/spec/javascripts/MongodbLoggerMainSpec.js +13 -0
  96. data/spec/javascripts/helpers/SpecHelper.js +3 -0
  97. data/spec/javascripts/support/jasmine.yml +77 -0
  98. data/spec/javascripts/support/jasmine_config.rb +23 -0
  99. data/spec/javascripts/support/jasmine_runner.rb +32 -0
  100. data/test/active_record.rb +13 -0
  101. data/test/config/samples/database.yml +9 -0
  102. data/test/config/samples/database_no_file_logging.yml +10 -0
  103. data/test/config/samples/database_replica_set.yml +12 -0
  104. data/test/config/samples/database_with_auth.yml +9 -0
  105. data/test/config/samples/database_with_collection.yml +8 -0
  106. data/test/config/samples/mongodb_logger.yml +2 -0
  107. data/test/config/samples/mongoid.yml +30 -0
  108. data/test/config/samples/server_config.yml +3 -0
  109. data/test/rails/app/controllers/order_controller.rb +23 -0
  110. data/test/rails/test/functional/order_controller_test.rb +116 -0
  111. data/test/rails/test/test_helper.rb +10 -0
  112. data/test/rails.rb +22 -0
  113. data/test/shoulda_macros/log_macros.rb +13 -0
  114. data/test/test.sh +6 -0
  115. data/test/test_helper.rb +89 -0
  116. data/test/unit/mongodb_logger_replica_test.rb +56 -0
  117. data/test/unit/mongodb_logger_test.rb +270 -0
  118. metadata +383 -0
@@ -0,0 +1,174 @@
1
+ require 'sinatra/base'
2
+ require 'erubis'
3
+ require 'json'
4
+ require 'active_support'
5
+
6
+ require 'mongodb_logger/server/view_helpers'
7
+ require 'mongodb_logger/server/partials'
8
+ require 'mongodb_logger/server/content_for'
9
+
10
+ require 'mongodb_logger/server/model/additional_filter'
11
+ require 'mongodb_logger/server/model/filter'
12
+ require 'mongodb_logger/server/model/analytic'
13
+
14
+ require 'mongodb_logger/server_config'
15
+
16
+ if defined? Encoding
17
+ Encoding.default_external = Encoding::UTF_8
18
+ end
19
+
20
+ module MongodbLogger
21
+ class Server < Sinatra::Base
22
+ helpers Sinatra::ViewHelpers
23
+ helpers Sinatra::Partials
24
+ helpers Sinatra::ContentFor
25
+
26
+ dir = File.dirname(File.expand_path(__FILE__))
27
+
28
+ set :views, "#{dir}/server/views"
29
+
30
+ if respond_to? :public_folder
31
+ set :public_folder, "#{dir}/server/public"
32
+ else
33
+ set :public, "#{dir}/server/public"
34
+ end
35
+ #set :environment, :production
36
+ set :static, true
37
+
38
+ helpers do
39
+ include Rack::Utils
40
+ alias_method :h, :escape_html
41
+
42
+ def current_page
43
+ url_path request.path_info.sub('/','')
44
+ end
45
+
46
+ def class_if_current(path = '')
47
+ 'class="active"' if current_page[0, path.size] == path
48
+ end
49
+
50
+ def url_path(*path_parts)
51
+ [ path_prefix, path_parts ].join("/").squeeze('/')
52
+ end
53
+ alias_method :u, :url_path
54
+
55
+ def path_prefix
56
+ request.env['SCRIPT_NAME']
57
+ end
58
+
59
+ end
60
+
61
+ before do
62
+ begin
63
+ if ServerConfig.db && ServerConfig.collection
64
+ @db = ServerConfig.db
65
+ @collection = ServerConfig.collection
66
+ else
67
+ @db = Rails.logger.mongo_connection
68
+ @collection = @db[Rails.logger.mongo_collection_name]
69
+ end
70
+ @collection_stats = @collection.stats
71
+ rescue => e
72
+ erb :error, {:layout => false}, :error => "Can't connect to MongoDB!"
73
+ return false
74
+ end
75
+
76
+ cache_control :private, :must_revalidate, :max_age => 0
77
+ end
78
+
79
+ def show(page, layout = true)
80
+ begin
81
+ erb page.to_sym, {:layout => layout}
82
+ rescue => e
83
+ erb :error, {:layout => false}, :error => "Error in view. Debug: #{e.inspect}"
84
+ end
85
+ end
86
+
87
+
88
+ get "/?" do
89
+ redirect url_path(:overview)
90
+ end
91
+
92
+ %w( overview ).each do |page|
93
+ get "/#{page}/?" do
94
+ @filter = ServerModel::Filter.new(params[:filter])
95
+ @logs = @collection.find(@filter.get_mongo_conditions).sort('$natural', -1).limit(@filter.get_mongo_limit)
96
+ show page, !request.xhr?
97
+ end
98
+ end
99
+
100
+ get "/tail_logs/?:log_last_id?" do
101
+ buffer = []
102
+ last_id = nil
103
+ if params[:log_last_id] && !params[:log_last_id].blank?
104
+ log_last_id = params[:log_last_id]
105
+ tail = Mongo::Cursor.new(@collection, :tailable => true, :order => [['$natural', 1]],
106
+ :selector => {'_id' => { '$gt' => BSON::ObjectId(log_last_id) }})
107
+ while log = tail.next
108
+ buffer << partial(:"shared/log", :object => log)
109
+ log_last_id = log["_id"].to_s
110
+ end
111
+ buffer.reverse!
112
+ else
113
+ @log = @collection.find_one({}, {:sort => ['$natural', -1]})
114
+ log_last_id = @log["_id"].to_s unless @log.blank?
115
+ end
116
+
117
+ content_type :json
118
+ { :log_last_id => log_last_id,
119
+ :time => Time.now.strftime("%F %T"),
120
+ :content => buffer.join("\n"),
121
+ :collection_stats => partial(:"shared/collection_stats", :object => @collection_stats) }.to_json
122
+ end
123
+
124
+ get "/changed_filter/:type" do
125
+ type_id = ServerModel::AdditionalFilter.get_type_index params[:type]
126
+ conditions = ServerModel::AdditionalFilter::VAR_TYPE_CONDITIONS[type_id]
127
+ values = ServerModel::AdditionalFilter::VAR_TYPE_VALUES[type_id]
128
+
129
+ content_type :json
130
+ {
131
+ :type_id => type_id,
132
+ :conditions => conditions,
133
+ :values => values
134
+ }.to_json
135
+ end
136
+
137
+ # log info
138
+ get "/log/:id" do
139
+ @log = @collection.find_one(BSON::ObjectId(params[:id]))
140
+ show :show_log, !request.xhr?
141
+ end
142
+
143
+ # log info right
144
+ get "/log_info/:id" do
145
+ @log = @collection.find_one(BSON::ObjectId(params[:id]))
146
+ partial(:"shared/log_info", :object => @log)
147
+ end
148
+
149
+ get "/add_filter/?" do
150
+ @filter = ServerModel::Filter.new(nil)
151
+ @filter_more = ServerModel::AdditionalFilter.new(nil, @filter)
152
+ partial(:"shared/dynamic_filter", :object => @filter_more)
153
+ end
154
+
155
+ # analytics
156
+ %w( analytics ).each do |page|
157
+ get "/#{page}/?" do
158
+ @analytic = ServerModel::Analytic.new(@collection, params[:analytic])
159
+ show page, !request.xhr?
160
+ end
161
+ post "/#{page}/?" do
162
+ @analytic = ServerModel::Analytic.new(@collection, params[:analytic])
163
+ @analytic_data = @analytic.get_data
164
+ content_type :json
165
+ @analytic_data.to_json
166
+ end
167
+ end
168
+
169
+ error do
170
+ erb :error, {:layout => false}, :error => 'Sorry there was a nasty error. Maybe no connection to MongoDB. Debug: ' + env['sinatra.error'].inspect
171
+ end
172
+
173
+ end
174
+ end
@@ -0,0 +1,77 @@
1
+ require 'mongo'
2
+ require 'erb'
3
+ require 'active_support'
4
+ require 'active_support/core_ext'
5
+
6
+ # TODO: Dry this class with logger class
7
+ module MongodbLogger
8
+ class ServerConfig
9
+
10
+ DEFAULT_COLLECTION_SIZE = 250.megabytes
11
+
12
+ class << self
13
+
14
+ def set_config(config_path)
15
+ if File.file?(config_path)
16
+ config_file = File.new(config_path)
17
+ config = YAML.load(ERB.new(config_file.read).result)
18
+ else
19
+ raise "Config file not found"
20
+ end
21
+
22
+ @db_configuration = {
23
+ 'host' => 'localhost',
24
+ 'port' => 27017}.merge(config)
25
+ @db_configuration["collection"] ||= "production_log"
26
+ @db = Mongo::Connection.new(@db_configuration['host'],
27
+ @db_configuration['port'],
28
+ :auto_reconnect => true).db(@db_configuration['database'])
29
+
30
+ if @db_configuration['username'] && @db_configuration['password']
31
+ @authenticated = @db.authenticate(@db_configuration['username'],
32
+ @db_configuration['password'])
33
+ end
34
+
35
+ set_collection
36
+ end
37
+
38
+ def set_config_for_testing(config_path)
39
+ set_config(config_path)
40
+ create_collection unless @db.collection_names.include?(@db_configuration["collection"])
41
+ set_collection
42
+ end
43
+
44
+ def create_collection
45
+ capsize = DEFAULT_COLLECTION_SIZE
46
+ capsize = @db_configuration['capsize'].to_i if @db_configuration['capsize']
47
+ @db.create_collection(@db_configuration["collection"],
48
+ {:capped => true, :size => capsize})
49
+ end
50
+
51
+
52
+ def set_collection
53
+ @collection = @db[@db_configuration["collection"]]
54
+ end
55
+
56
+ def get_config
57
+ @db_configuration
58
+ end
59
+
60
+ def authenticated?
61
+ @authenticated
62
+ end
63
+
64
+ def collection_name
65
+ @db_configuration["collection"]
66
+ end
67
+
68
+ def db
69
+ @db
70
+ end
71
+
72
+ def collection
73
+ @collection
74
+ end
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,3 @@
1
+ module MongodbLogger
2
+ VERSION = "0.2.6"
3
+ end
@@ -0,0 +1,31 @@
1
+ $:.unshift File.dirname(__FILE__)
2
+
3
+ require 'mongo'
4
+ require 'mongodb_logger/logger'
5
+ require 'mongodb_logger/railtie' if defined?(Rails::Railtie)
6
+ require 'mongodb_logger/version'
7
+
8
+ module MongodbLogger
9
+ module Base
10
+ def self.included(base)
11
+ base.class_eval { around_filter :enable_mongodb_logger }
12
+ end
13
+
14
+ def enable_mongodb_logger
15
+ return yield unless Rails.logger.respond_to?(:mongoize)
16
+ f_params = case
17
+ when request.respond_to?(:filtered_parameters) then request.filtered_parameters
18
+ else params
19
+ end
20
+ Rails.logger.mongoize({
21
+ :method => request.method,
22
+ :action => action_name,
23
+ :controller => controller_name,
24
+ :path => request.path,
25
+ :url => request.url,
26
+ :params => f_params,
27
+ :ip => request.remote_ip
28
+ }) { yield }
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,44 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/mongodb_logger/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Alexey Vasiliev"]
6
+ gem.email = ["leopard.not.a@gmail.com"]
7
+ gem.description = %q{MongoDB logger for Rails 3}
8
+ gem.summary = %q{MongoDB logger for Rails 3}
9
+ gem.homepage = "http://mongodb-logger.catware.org"
10
+
11
+ gem.extra_rdoc_files = [ "LICENSE", "README.md" ]
12
+ gem.rdoc_options = ["--charset=UTF-8"]
13
+
14
+ gem.add_development_dependency "jasmine", ">= 1.0.0"
15
+ gem.add_development_dependency "rspec", ">= 2.8.0"
16
+ gem.add_development_dependency "shoulda", ">= 2.0.0"
17
+ gem.add_development_dependency "mocha", ">= 0.10.0"
18
+ gem.add_development_dependency "cucumber", "~> 1.1.2"
19
+ gem.add_development_dependency "capybara", "~> 1.1.2"
20
+ gem.add_development_dependency "coffee-script", "~> 2.2.0"
21
+ gem.add_development_dependency "uglifier", ">= 1.2.0"
22
+ gem.add_development_dependency "therubyracer", ">= 0.9.9"
23
+
24
+ gem.add_runtime_dependency "rake", "~> 0.9.0"
25
+ gem.add_runtime_dependency "mongo", "~> 1.5.2"
26
+ gem.add_runtime_dependency "bson_ext", "~> 1.5.2"
27
+ gem.add_runtime_dependency "i18n", ">= 0.4.1"
28
+ gem.add_runtime_dependency "json", "~> 1.6.1"
29
+ gem.add_runtime_dependency "activesupport", ">= 3.0.0"
30
+ gem.add_runtime_dependency "actionpack", ">= 3.0.0"
31
+ gem.add_runtime_dependency "sinatra", ">= 1.2.0"
32
+ gem.add_runtime_dependency "erubis", ">= 2.6.6"
33
+ gem.add_runtime_dependency "vegas", "~> 0.1.2"
34
+
35
+ gem.rubyforge_project = "mongodb_logger"
36
+
37
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
38
+ gem.files = `git ls-files`.split("\n")
39
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
40
+ gem.name = "mongodb_logger"
41
+ gem.require_paths = ["lib"]
42
+ gem.version = MongodbLogger::VERSION
43
+ gem.platform = Gem::Platform::RUBY
44
+ end
@@ -0,0 +1,42 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/mongodb_logger/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Alexey Vasiliev"]
6
+ gem.email = ["leopard.not.a@gmail.com"]
7
+ gem.description = %q{MongoDB logger for Rails 3}
8
+ gem.summary = %q{MongoDB logger for Rails 3}
9
+ gem.homepage = "http://mongodb-logger.catware.org"
10
+
11
+ gem.extra_rdoc_files = [ "LICENSE", "README.md" ]
12
+ gem.rdoc_options = ["--charset=UTF-8"]
13
+
14
+ gem.add_development_dependency "jasmine", ">= 1.0.0"
15
+ gem.add_development_dependency "rspec", ">= 2.8.0"
16
+ gem.add_development_dependency "shoulda", ">= 2.0.0"
17
+ gem.add_development_dependency "mocha", ">= 0.10.0"
18
+ gem.add_development_dependency "cucumber", "~> 1.1.2"
19
+ gem.add_development_dependency "capybara", "~> 1.1.2"
20
+ gem.add_development_dependency "coffee-script", "~> 2.2.0"
21
+ gem.add_development_dependency "uglifier", ">= 1.2.0"
22
+
23
+ gem.add_runtime_dependency "rake", "~> 0.9.0"
24
+ gem.add_runtime_dependency "mongo", "~> 1.5.2"
25
+ gem.add_runtime_dependency "i18n", ">= 0.4.1"
26
+ gem.add_runtime_dependency "json", "~> 1.6.1"
27
+ gem.add_runtime_dependency "activesupport", ">= 3.0.0"
28
+ gem.add_runtime_dependency "actionpack", ">= 3.0.0"
29
+ gem.add_runtime_dependency "sinatra", ">= 1.2.0"
30
+ gem.add_runtime_dependency "erubis", ">= 2.6.6"
31
+ gem.add_runtime_dependency "vegas", "~> 0.1.2"
32
+
33
+ gem.rubyforge_project = "mongodb_logger"
34
+
35
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
36
+ gem.files = `git ls-files`.split("\n")
37
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
38
+ gem.name = "mongodb_logger"
39
+ gem.require_paths = ["lib"]
40
+ gem.version = MongodbLogger::VERSION
41
+ gem.platform = "jruby"
42
+ end
@@ -0,0 +1,13 @@
1
+ describe("MongodbLoggerMain", function() {
2
+
3
+ beforeEach(function() {
4
+ MongodbLoggerMain.init();
5
+ });
6
+
7
+ describe("log_info_padding", function() {
8
+ it("should be 15", function() {
9
+ expect(MongodbLoggerMain.log_info_padding).toEqual(15);
10
+ });
11
+ });
12
+
13
+ });
@@ -0,0 +1,3 @@
1
+ beforeEach(function() {
2
+ /**/
3
+ });
@@ -0,0 +1,77 @@
1
+ # src_files
2
+ #
3
+ # Return an array of filepaths relative to src_dir to include before jasmine specs.
4
+ # Default: []
5
+ #
6
+ # EXAMPLE:
7
+ #
8
+ # src_files:
9
+ # - lib/source1.js
10
+ # - lib/source2.js
11
+ # - dist/**/*.js
12
+ #
13
+ src_files:
14
+ - lib/mongodb_logger/server/public/javascripts/vendors/jquery-1.7.1.min.js
15
+ - lib/mongodb_logger/server/public/javascripts/vendors/jquery-ui-1.8.16.min.js
16
+ - lib/mongodb_logger/server/public/javascripts/vendors/jquery.pjax.min.js
17
+ - lib/mongodb_logger/server/public/javascripts/vendors/highlight.pack.js
18
+ - lib/mongodb_logger/server/public/javascripts/logs.js
19
+
20
+ # stylesheets
21
+ #
22
+ # Return an array of stylesheet filepaths relative to src_dir to include before jasmine specs.
23
+ # Default: []
24
+ #
25
+ # EXAMPLE:
26
+ #
27
+ # stylesheets:
28
+ # - css/style.css
29
+ # - stylesheets/*.css
30
+ #
31
+ stylesheets:
32
+
33
+ # helpers
34
+ #
35
+ # Return an array of filepaths relative to spec_dir to include before jasmine specs.
36
+ # Default: ["helpers/**/*.js"]
37
+ #
38
+ # EXAMPLE:
39
+ #
40
+ # helpers:
41
+ # - helpers/**/*.js
42
+ #
43
+ helpers:
44
+
45
+ # spec_files
46
+ #
47
+ # Return an array of filepaths relative to spec_dir to include.
48
+ # Default: ["**/*[sS]pec.js"]
49
+ #
50
+ # EXAMPLE:
51
+ #
52
+ # spec_files:
53
+ # - **/*[sS]pec.js
54
+ #
55
+ spec_files:
56
+
57
+ # src_dir
58
+ #
59
+ # Source directory path. Your src_files must be returned relative to this path. Will use root if left blank.
60
+ # Default: project root
61
+ #
62
+ # EXAMPLE:
63
+ #
64
+ # src_dir: public
65
+ #
66
+ src_dir:
67
+
68
+ # spec_dir
69
+ #
70
+ # Spec directory path. Your spec_files must be returned relative to this path.
71
+ # Default: spec/javascripts
72
+ #
73
+ # EXAMPLE:
74
+ #
75
+ # spec_dir: spec/javascripts
76
+ #
77
+ spec_dir:
@@ -0,0 +1,23 @@
1
+ module Jasmine
2
+ class Config
3
+
4
+ # Add your overrides or custom config code here
5
+
6
+ end
7
+ end
8
+
9
+
10
+ # Note - this is necessary for rspec2, which has removed the backtrace
11
+ module Jasmine
12
+ class SpecBuilder
13
+ def declare_spec(parent, spec)
14
+ me = self
15
+ example_name = spec["name"]
16
+ @spec_ids << spec["id"]
17
+ backtrace = @example_locations[parent.description + " " + example_name]
18
+ parent.it example_name, {} do
19
+ me.report_spec(spec["id"])
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,32 @@
1
+ $:.unshift(ENV['JASMINE_GEM_PATH']) if ENV['JASMINE_GEM_PATH'] # for gem testing purposes
2
+
3
+ require 'rubygems'
4
+ require 'jasmine'
5
+ jasmine_config_overrides = File.expand_path(File.join(File.dirname(__FILE__), 'jasmine_config.rb'))
6
+ require jasmine_config_overrides if File.exist?(jasmine_config_overrides)
7
+ if Jasmine::Dependencies.rspec2?
8
+ require 'rspec'
9
+ else
10
+ require 'spec'
11
+ end
12
+
13
+ jasmine_config = Jasmine::Config.new
14
+ spec_builder = Jasmine::SpecBuilder.new(jasmine_config)
15
+
16
+ should_stop = false
17
+
18
+ if Jasmine::Dependencies.rspec2?
19
+ RSpec.configuration.after(:suite) do
20
+ spec_builder.stop if should_stop
21
+ end
22
+ else
23
+ Spec::Runner.configure do |config|
24
+ config.after(:suite) do
25
+ spec_builder.stop if should_stop
26
+ end
27
+ end
28
+ end
29
+
30
+ spec_builder.start
31
+ should_stop = true
32
+ spec_builder.declare_suites
@@ -0,0 +1,13 @@
1
+ module ActiveRecord
2
+ class LogSubscriber
3
+ def self.colorize_logging
4
+ true
5
+ end
6
+ end
7
+
8
+ class Base
9
+ def self.colorize_logging
10
+ true
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ test:
2
+ adapter: sqlite3
3
+ database: db/test.sqlite3
4
+ pool: 5
5
+ timeout: 5000
6
+ mongodb_logger:
7
+ database: system_log
8
+ application_name: mongo_foo
9
+ safe_insert: true
@@ -0,0 +1,10 @@
1
+ test:
2
+ adapter: sqlite3
3
+ database: db/test.sqlite3
4
+ pool: 5
5
+ timeout: 5000
6
+ mongodb_logger:
7
+ database: system_log
8
+ application_name: mongo_foo
9
+ safe_insert: true
10
+ disable_file_logging: true
@@ -0,0 +1,12 @@
1
+ test:
2
+ adapter: mysql
3
+ username: user
4
+ database: database
5
+ mongodb_logger:
6
+ database: system_log
7
+ replica_set: true
8
+ hosts:
9
+ - - 127.0.0.1
10
+ - 27018
11
+ - - 127.0.0.1
12
+ - 27019
@@ -0,0 +1,9 @@
1
+ test:
2
+ adapter: sqlite3
3
+ database: db/test.sqlite3
4
+ pool: 5
5
+ timeout: 5000
6
+ mongodb_logger:
7
+ database: system_log
8
+ username: admin
9
+ password: password
@@ -0,0 +1,8 @@
1
+ test:
2
+ adapter: sqlite3
3
+ database: db/test.sqlite3
4
+ pool: 5
5
+ timeout: 5000
6
+ mongodb_logger:
7
+ database: system_log
8
+ collection: log_collection
@@ -0,0 +1,2 @@
1
+ test:
2
+ database: system_log
@@ -0,0 +1,30 @@
1
+ # taken from http://mongoid.org/docs/installation/
2
+ defaults: &defaults
3
+ host: localhost
4
+ slaves:
5
+ - host: slave1.local
6
+ port: 27018
7
+ - host: slave2.local
8
+ port: 27019
9
+ autocreate_indexes: false
10
+ allow_dynamic_fields: true
11
+ include_root_in_json: false
12
+ parameterize_keys: true
13
+ persist_in_safe_mode: false
14
+ raise_not_found_error: true
15
+ reconnect_time: 3
16
+
17
+ development:
18
+ <<: *defaults
19
+ database: control_development
20
+
21
+ test:
22
+ <<: *defaults
23
+ database: system_log
24
+
25
+ # set these environment variables on your prod server
26
+ production:
27
+ <<: *defaults
28
+ host: <%= ENV['MONGOID_HOST'] %>
29
+ port: <%= ENV['MONGOID_PORT'] %>
30
+ database: <%= ENV['MONGOID_DATABASE'] %>
@@ -0,0 +1,3 @@
1
+ database: test_database
2
+ host: localhost
3
+ port: 27017
@@ -0,0 +1,23 @@
1
+ class OrderController < ApplicationController
2
+ include MongodbLogger::Base
3
+ LOG_MESSAGE = "FOO"
4
+ LOG_USER_ID = 12345
5
+
6
+ def index
7
+ logger.debug LOG_MESSAGE
8
+ logger.add_metadata(:application_name_again => Rails.root.basename.to_s, :user_id => LOG_USER_ID)
9
+ render :text => "nothing"
10
+ end
11
+
12
+ def new
13
+ raise OrderController::LOG_MESSAGE
14
+ end
15
+
16
+ def create
17
+ render :text => "create"
18
+ end
19
+
20
+ def test_post
21
+ render :text => "done"
22
+ end
23
+ end