mongodb_logger 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Appraisals +2 -2
- data/CHANGELOG.md +2 -0
- data/README.md +15 -1
- data/gemfiles/rails31.gemfile +1 -1
- data/gemfiles/rails32.gemfile +1 -1
- data/lib/mongodb_logger/config.rb +10 -5
- data/lib/mongodb_logger/railtie.rb +1 -1
- data/lib/mongodb_logger/version.rb +1 -1
- data/spec/mongodb_logger_spec.rb +16 -14
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ae987b579d29c9e088ea907aa2679494a1df53c
|
4
|
+
data.tar.gz: a63a152e8ccf5ee8711bfcdfa199b95c9d59ad4c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b165d24c972e92d8f9924c979b2ca58d888bfd5f23ea229b60f1c2007df80f959e872eb51d518e210a1f577d60f05ac59e2ed5191254100644698df46a5e2126
|
7
|
+
data.tar.gz: 66224465afd039b229111975c3199c79536df085dd0a56bc94e9835f08363448425c4dadb3e7d29c31e838119f6598e253e5b7ebc5a3a376260227aeed3fee54
|
data/Appraisals
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -37,11 +37,13 @@ Doesn't support the Rails version below 3.
|
|
37
37
|
|
38
38
|
include MongodbLogger::Base
|
39
39
|
|
40
|
-
1. For use with Heroku you need to prevent the rails\_log\_stdout plugin from being added by Heroku:
|
40
|
+
1. For use with Heroku you need to prevent the rails\_log\_stdout plugin from being added by Heroku for rails 3:
|
41
41
|
|
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.
|
46
|
+
|
45
47
|
1. Add MongodbLogger settings to database.yml for each environment in which you want to use the MongodbLogger. The MongodbLogger will also
|
46
48
|
look for a separate mongodb\_logger.yml or mongoid.yml (if you are using mongoid) before looking in database.yml.
|
47
49
|
In the mongodb\_logger.yml and mongoid.yml case, the settings should be defined without the 'mongodb\_logger' subkey.
|
@@ -158,6 +160,18 @@ For send email or do something on exception you can add callback:
|
|
158
160
|
|
159
161
|
In this callback send record without "\_id", because logger not wait for insert response from MongoDB.
|
160
162
|
|
163
|
+
## Disable mongodb_logger
|
164
|
+
|
165
|
+
To disable MongodbLogger you can use option disable. But this should be set before rails load (for example in Rails app the top of "config/application.rb"):
|
166
|
+
|
167
|
+
MongodbLogger::Base.configure do |config|
|
168
|
+
config.disable = true
|
169
|
+
end
|
170
|
+
|
171
|
+
or
|
172
|
+
|
173
|
+
MongodbLogger::Base.disable = true
|
174
|
+
|
161
175
|
## Migrate to another size of capped collection
|
162
176
|
|
163
177
|
If you need change capper collection size, you should change the "capsize" key in mongodb\_config and run this task for migration:
|
data/gemfiles/rails31.gemfile
CHANGED
data/gemfiles/rails32.gemfile
CHANGED
@@ -2,19 +2,20 @@ module MongodbLogger
|
|
2
2
|
# Change config options in an initializer:
|
3
3
|
#
|
4
4
|
# MongodbLogger::Base.on_log_exception do |mongo_record|
|
5
|
-
# ... call some code ...
|
5
|
+
# ... call some code ...
|
6
6
|
# end
|
7
7
|
#
|
8
8
|
# Or in a block:
|
9
9
|
#
|
10
10
|
# MongodbLogger::Base.configure do |config|
|
11
11
|
# config.on_log_exception do |mongo_record|
|
12
|
-
# ... call some code ...
|
12
|
+
# ... call some code ...
|
13
13
|
# end
|
14
14
|
# end
|
15
15
|
|
16
16
|
module Config
|
17
|
-
|
17
|
+
extend self
|
18
|
+
attr_writer :on_log_exception, :disabled
|
18
19
|
|
19
20
|
def configure
|
20
21
|
yield self
|
@@ -25,8 +26,12 @@ module MongodbLogger
|
|
25
26
|
@on_log_exception = block
|
26
27
|
elsif @on_log_exception
|
27
28
|
@on_log_exception.call(*args)
|
28
|
-
end
|
29
|
+
end
|
29
30
|
end
|
30
|
-
|
31
|
+
|
32
|
+
def disabled
|
33
|
+
@disabled ||= false
|
34
|
+
end
|
35
|
+
|
31
36
|
end
|
32
37
|
end
|
@@ -4,7 +4,7 @@ module MongodbLogger
|
|
4
4
|
include MongodbLogger::InitializerMixin
|
5
5
|
|
6
6
|
initializer :initialize_mongodb_logger, before: :initialize_logger do
|
7
|
-
Rails.logger = config.logger = create_logger(Rails.application.config)
|
7
|
+
Rails.logger = config.logger = create_logger(Rails.application.config) unless MongodbLogger::Base.disabled
|
8
8
|
end
|
9
9
|
|
10
10
|
rake_tasks do
|
data/spec/mongodb_logger_spec.rb
CHANGED
@@ -192,24 +192,26 @@ describe MongodbLogger::Logger do
|
|
192
192
|
end
|
193
193
|
|
194
194
|
context "after configure" do
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
195
|
+
context "#on_log_exception" do
|
196
|
+
before do
|
197
|
+
MongodbLogger::Base.configure do |config|
|
198
|
+
config.on_log_exception do |mongo_record|
|
199
|
+
# do something with error
|
200
|
+
end
|
199
201
|
end
|
202
|
+
common_mongodb_logger_setup
|
200
203
|
end
|
201
|
-
common_mongodb_logger_setup
|
202
|
-
end
|
203
204
|
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
205
|
+
it "not call callback function on log" do
|
206
|
+
MongodbLogger::Base.should_receive(:on_log_exception).exactly(0)
|
207
|
+
log_to_mongo("Test")
|
208
|
+
end
|
208
209
|
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
210
|
+
context "when an exception is raised" do
|
211
|
+
it "should call callback function" do
|
212
|
+
MongodbLogger::Base.should_receive(:on_log_exception).exactly(1)
|
213
|
+
expect { log_exception_to_mongo(EXCEPTION_MSG) }.to raise_error RuntimeError, EXCEPTION_MSG
|
214
|
+
end
|
213
215
|
end
|
214
216
|
end
|
215
217
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongodb_logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexey Vasiliev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|