mongoid_appender 0.0.2

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 +7 -0
  2. data/lib/mongoid_appender.rb +56 -0
  3. metadata +102 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c4ebcdaf6137666eee627b1f3ad194f3211ccb49
4
+ data.tar.gz: 775be6e2b9a249707e09af4f16b5bb52bd0d5f8c
5
+ SHA512:
6
+ metadata.gz: 7058b73cbcadd63389b8ced2d7561a9761973097f2c9c426efcd90a76d8f446e0e6ae99cb5becf05d05e4de9b4d3b2ae1064ffeacc36eadf5cc5ea44f875f5cc
7
+ data.tar.gz: af8c8730a74894d0221a043fa21c71397dc3c38172b29cd720c08a824d820a0e9805fb4379792860d81453098dd8a13d8c74a13ebde27484f3c98658a6f736dd
@@ -0,0 +1,56 @@
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
56
+ end
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mongoid_appender
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Jonathan Wong
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: logging
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 1.8.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 1.8.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: mongoid
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 3.0.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 3.0.0
69
+ description:
70
+ email:
71
+ - jonathan@armchairtheorist.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - lib/mongoid_appender.rb
77
+ homepage: http://github.com/armchairtheorist/mongoid_appender
78
+ licenses:
79
+ - MIT
80
+ metadata: {}
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubyforge_project:
97
+ rubygems_version: 2.4.1
98
+ signing_key:
99
+ specification_version: 4
100
+ summary: Simple implementation of a logging appender for Tim Pease's Logging framework
101
+ using Mongoid.
102
+ test_files: []