mongoid_appender 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/mongoid_appender.rb +49 -55
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c4ebcdaf6137666eee627b1f3ad194f3211ccb49
4
- data.tar.gz: 775be6e2b9a249707e09af4f16b5bb52bd0d5f8c
3
+ metadata.gz: 51cdfdbbaf845cdce306a12c46c6fbeba1348d26
4
+ data.tar.gz: 45ce99b204ae44503993795b6dea827a3f78a102
5
5
  SHA512:
6
- metadata.gz: 7058b73cbcadd63389b8ced2d7561a9761973097f2c9c426efcd90a76d8f446e0e6ae99cb5becf05d05e4de9b4d3b2ae1064ffeacc36eadf5cc5ea44f875f5cc
7
- data.tar.gz: af8c8730a74894d0221a043fa21c71397dc3c38172b29cd720c08a824d820a0e9805fb4379792860d81453098dd8a13d8c74a13ebde27484f3c98658a6f736dd
6
+ metadata.gz: 6da5a28809f0c904ee8d73c004d383b3e0bd46f9a10083c2cb6e172e18146b9742f02c89dbef1b50222c677999a856a90b566b7aea4b05d85369f06769a32ca9
7
+ data.tar.gz: 7a2668700b44ed95f600b027bff21328a7cb157b7b670c167613dd3507f853e7a1084ea203f5b8c20e7062187ebf01f4803f35b5c5c95e00a4d7dba1ac4dbce3
@@ -1,56 +1,50 @@
1
- require "logging"
2
- require "mongoid"
3
-
4
- class MongoidAppender < Logging::Appender
5
-
6
- VERSION = "0.0.2"
7
-
8
- class Log
9
- include Mongoid::Document
10
- include Mongoid::Timestamps::Created
11
-
12
- store_in collection: "logs"
13
-
14
- field :level, type: String
15
- field :logger, type: String
16
- field :message, type: String
17
- field :exception, type: String
18
- field :backtrace, type: Array
19
-
20
- index({ level: 1})
21
- index({ logger: 1})
22
- index({ exception: 1})
23
- end
24
-
25
- def initialize (name, opts = {})
26
- super(name, opts)
27
- end
28
-
29
- def write (event)
30
- if event.instance_of?(Logging::LogEvent)
31
- if event.data.is_a?(Exception)
32
- Log.create!(
33
- level: Logging::LNAMES[event.level],
34
- logger: event.logger,
35
- message: event.data.message,
36
- exception: event.data.class.to_s,
37
- backtrace: event.data.backtrace
38
- )
39
- else
40
- Log.create!(
41
- level: Logging::LNAMES[event.level],
42
- logger: event.logger,
43
- message: event.data.to_s
44
- )
45
- end
46
- else
47
- text = event.to_s
48
-
49
- Log.create!(
50
- level: text.split(" ")[0],
51
- logger: text.split(" ")[1],
52
- message: text[text.index(" : ") + 3..-1].split("\n\t")[0]
53
- ) unless text.empty?
54
- end
55
- end
1
+ require "logging"
2
+ require "mongoid"
3
+
4
+ class MongoidAppender < Logging::Appender
5
+
6
+ VERSION = "0.0.3"
7
+
8
+ class Log
9
+ include Mongoid::Document
10
+ include Mongoid::Timestamps::Created
11
+
12
+ store_in collection: "logs"
13
+
14
+ field :level, type: String
15
+ field :logger, type: String
16
+ field :message, type: String
17
+ field :exception, type: String
18
+ field :backtrace, type: Array
19
+
20
+ index({ level: 1})
21
+ index({ logger: 1})
22
+ index({ exception: 1})
23
+ end
24
+
25
+ def initialize (name, opts = {})
26
+ super(name, opts)
27
+ end
28
+
29
+ def write (event)
30
+ if event.instance_of?(Logging::LogEvent)
31
+ if event.data.is_a?(Exception)
32
+ Log.create!(
33
+ level: Logging::LNAMES[event.level],
34
+ logger: event.logger,
35
+ message: event.data.message,
36
+ exception: event.data.class.to_s,
37
+ backtrace: event.data.backtrace
38
+ )
39
+ else
40
+ Log.create!(
41
+ level: Logging::LNAMES[event.level],
42
+ logger: event.logger,
43
+ message: event.data.to_s
44
+ )
45
+ end
46
+ else
47
+ Log.create!(message: event.to_s)
48
+ end
49
+ end
56
50
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid_appender
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Wong
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-24 00:00:00.000000000 Z
11
+ date: 2014-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler