rf_logger 0.0.4 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.rspec +1 -1
- data/.travis.yml +3 -0
- data/README.md +99 -2
- data/lib/rf_logger/active_record/logger.rb +35 -0
- data/lib/rf_logger/active_record.rb +1 -0
- data/lib/rf_logger/configuration.rb +1 -1
- data/lib/rf_logger/notifications/error_notification_environment_constraints.rb +2 -1
- data/lib/rf_logger/rails/initialize_request_middleware.rb +9 -0
- data/lib/rf_logger/rails/key_value_tagged_logging.rb +58 -0
- data/lib/rf_logger/rails/rails_compatibility.rb +33 -0
- data/lib/rf_logger/rails.rb +5 -0
- data/lib/rf_logger/request/request_headers.rb +34 -0
- data/lib/rf_logger/request/request_middleware.rb +30 -0
- data/lib/rf_logger/request/request_tags.rb +9 -0
- data/lib/rf_logger/rory/initialize_request_middleware.rb +7 -0
- data/lib/rf_logger/rory.rb +2 -0
- data/lib/rf_logger/sequel/base.rb +46 -0
- data/lib/rf_logger/sequel/logger.rb +53 -0
- data/lib/rf_logger/sequel.rb +2 -0
- data/lib/rf_logger/version.rb +1 -1
- data/lib/rf_logger.rb +13 -42
- data/rf_logger.gemspec +5 -5
- data/spec/lib/rf_logger/active_record/logger_spec.rb +49 -0
- data/spec/lib/rf_logger/configuration_spec.rb +19 -14
- data/spec/lib/rf_logger/log_for_notification_spec.rb +3 -3
- data/spec/lib/rf_logger/notifications/error_notification_environment_constraints_spec.rb +26 -12
- data/spec/lib/rf_logger/notifications/error_notification_spec.rb +9 -9
- data/spec/lib/rf_logger/rails/rails_compatibility_spec.rb +42 -0
- data/spec/lib/rf_logger/request/request_headers_spec.rb +83 -0
- data/spec/lib/rf_logger/request/request_middleware_spec.rb +35 -0
- data/spec/lib/rf_logger/{sequel_logger_spec.rb → sequel/logger_spec.rb} +46 -16
- data/spec/lib/rf_logger/simple_logger_spec.rb +8 -8
- data/spec/lib/rf_logger_spec.rb +8 -6
- data/spec/spec_helper.rb +2 -1
- data/spec/support/request_id_shared_examples.rb +21 -0
- metadata +63 -37
- data/lib/rf_logger/sequel_logger.rb +0 -41
@@ -0,0 +1,21 @@
|
|
1
|
+
RSpec.shared_context "RfLogger::RequestId" do |subject:|
|
2
|
+
describe "#rf_logger_request_tags" do
|
3
|
+
before {allow(subject).to receive(:rf_logger_request_tags).and_call_original}
|
4
|
+
context "When thread var inheritable_attributes is nil" do
|
5
|
+
before { Thread.current[:inheritable_attributes] = nil }
|
6
|
+
it { expect(subject.rf_logger_request_tags).to eq(nil) }
|
7
|
+
end
|
8
|
+
|
9
|
+
context "when thread var inheritable_attributes is empty hash" do
|
10
|
+
before { Thread.current[:inheritable_attributes] = {} }
|
11
|
+
it { expect(subject.rf_logger_request_tags).to eq(nil) }
|
12
|
+
end
|
13
|
+
|
14
|
+
context "when thread var inheritable_attributes has key rf_logger_request_tags" do
|
15
|
+
before { Thread.current[:inheritable_attributes] = { rf_logger_request_tags: { hello: "goodbye" } } }
|
16
|
+
it { expect(subject.rf_logger_request_tags).to eq({ hello: "goodbye" }) }
|
17
|
+
end
|
18
|
+
|
19
|
+
before { Thread.current[:inheritable_attributes] = nil }
|
20
|
+
end
|
21
|
+
end
|
metadata
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rf_logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
+
- Dustin Zeisler
|
7
8
|
- Dave Miller
|
8
9
|
- Laurie Kemmerer
|
9
10
|
- Maher Hawash
|
@@ -14,101 +15,101 @@ cert_chain: []
|
|
14
15
|
date: 2014-02-20 00:00:00.000000000 Z
|
15
16
|
dependencies:
|
16
17
|
- !ruby/object:Gem::Dependency
|
17
|
-
name:
|
18
|
+
name: thread-inheritable_attributes
|
18
19
|
requirement: !ruby/object:Gem::Requirement
|
19
20
|
requirements:
|
20
|
-
- - ~>
|
21
|
+
- - "~>"
|
21
22
|
- !ruby/object:Gem::Version
|
22
|
-
version: '1
|
23
|
-
type: :
|
23
|
+
version: '0.1'
|
24
|
+
type: :runtime
|
24
25
|
prerelease: false
|
25
26
|
version_requirements: !ruby/object:Gem::Requirement
|
26
27
|
requirements:
|
27
|
-
- - ~>
|
28
|
+
- - "~>"
|
28
29
|
- !ruby/object:Gem::Version
|
29
|
-
version: '1
|
30
|
+
version: '0.1'
|
30
31
|
- !ruby/object:Gem::Dependency
|
31
|
-
name:
|
32
|
+
name: bundler
|
32
33
|
requirement: !ruby/object:Gem::Requirement
|
33
34
|
requirements:
|
34
|
-
- -
|
35
|
+
- - "~>"
|
35
36
|
- !ruby/object:Gem::Version
|
36
|
-
version: '
|
37
|
+
version: '1.3'
|
37
38
|
type: :development
|
38
39
|
prerelease: false
|
39
40
|
version_requirements: !ruby/object:Gem::Requirement
|
40
41
|
requirements:
|
41
|
-
- -
|
42
|
+
- - "~>"
|
42
43
|
- !ruby/object:Gem::Version
|
43
|
-
version: '
|
44
|
+
version: '1.3'
|
44
45
|
- !ruby/object:Gem::Dependency
|
45
|
-
name:
|
46
|
+
name: rake
|
46
47
|
requirement: !ruby/object:Gem::Requirement
|
47
48
|
requirements:
|
48
|
-
- -
|
49
|
+
- - ">="
|
49
50
|
- !ruby/object:Gem::Version
|
50
51
|
version: '0'
|
51
52
|
type: :development
|
52
53
|
prerelease: false
|
53
54
|
version_requirements: !ruby/object:Gem::Requirement
|
54
55
|
requirements:
|
55
|
-
- -
|
56
|
+
- - ">="
|
56
57
|
- !ruby/object:Gem::Version
|
57
58
|
version: '0'
|
58
59
|
- !ruby/object:Gem::Dependency
|
59
|
-
name:
|
60
|
+
name: rspec
|
60
61
|
requirement: !ruby/object:Gem::Requirement
|
61
62
|
requirements:
|
62
|
-
- -
|
63
|
+
- - "~>"
|
63
64
|
- !ruby/object:Gem::Version
|
64
|
-
version: '
|
65
|
+
version: '3.4'
|
65
66
|
type: :development
|
66
67
|
prerelease: false
|
67
68
|
version_requirements: !ruby/object:Gem::Requirement
|
68
69
|
requirements:
|
69
|
-
- -
|
70
|
+
- - "~>"
|
70
71
|
- !ruby/object:Gem::Version
|
71
|
-
version: '
|
72
|
+
version: '3.4'
|
72
73
|
- !ruby/object:Gem::Dependency
|
73
|
-
name:
|
74
|
+
name: simplecov
|
74
75
|
requirement: !ruby/object:Gem::Requirement
|
75
76
|
requirements:
|
76
|
-
- -
|
77
|
+
- - ">="
|
77
78
|
- !ruby/object:Gem::Version
|
78
79
|
version: '0'
|
79
80
|
type: :development
|
80
81
|
prerelease: false
|
81
82
|
version_requirements: !ruby/object:Gem::Requirement
|
82
83
|
requirements:
|
83
|
-
- -
|
84
|
+
- - ">="
|
84
85
|
- !ruby/object:Gem::Version
|
85
86
|
version: '0'
|
86
87
|
- !ruby/object:Gem::Dependency
|
87
|
-
name:
|
88
|
+
name: sequel
|
88
89
|
requirement: !ruby/object:Gem::Requirement
|
89
90
|
requirements:
|
90
|
-
- -
|
91
|
+
- - ">="
|
91
92
|
- !ruby/object:Gem::Version
|
92
93
|
version: '0'
|
93
94
|
type: :development
|
94
95
|
prerelease: false
|
95
96
|
version_requirements: !ruby/object:Gem::Requirement
|
96
97
|
requirements:
|
97
|
-
- -
|
98
|
+
- - ">="
|
98
99
|
- !ruby/object:Gem::Version
|
99
100
|
version: '0'
|
100
101
|
- !ruby/object:Gem::Dependency
|
101
|
-
name:
|
102
|
+
name: activerecord
|
102
103
|
requirement: !ruby/object:Gem::Requirement
|
103
104
|
requirements:
|
104
|
-
- -
|
105
|
+
- - ">="
|
105
106
|
- !ruby/object:Gem::Version
|
106
107
|
version: '0'
|
107
108
|
type: :development
|
108
109
|
prerelease: false
|
109
110
|
version_requirements: !ruby/object:Gem::Requirement
|
110
111
|
requirements:
|
111
|
-
- -
|
112
|
+
- - ">="
|
112
113
|
- !ruby/object:Gem::Version
|
113
114
|
version: '0'
|
114
115
|
description: A logger that allows specification of severity, applicable entity/records,
|
@@ -118,29 +119,48 @@ executables: []
|
|
118
119
|
extensions: []
|
119
120
|
extra_rdoc_files: []
|
120
121
|
files:
|
121
|
-
- .gitignore
|
122
|
-
- .rspec
|
122
|
+
- ".gitignore"
|
123
|
+
- ".rspec"
|
124
|
+
- ".travis.yml"
|
123
125
|
- Gemfile
|
124
126
|
- README.md
|
125
127
|
- Rakefile
|
126
128
|
- lib/rf_logger.rb
|
129
|
+
- lib/rf_logger/active_record.rb
|
130
|
+
- lib/rf_logger/active_record/logger.rb
|
127
131
|
- lib/rf_logger/configuration.rb
|
128
132
|
- lib/rf_logger/levels.rb
|
129
133
|
- lib/rf_logger/log_for_notification.rb
|
130
134
|
- lib/rf_logger/notifications/error_notification.rb
|
131
135
|
- lib/rf_logger/notifications/error_notification_environment_constraints.rb
|
132
|
-
- lib/rf_logger/
|
136
|
+
- lib/rf_logger/rails.rb
|
137
|
+
- lib/rf_logger/rails/initialize_request_middleware.rb
|
138
|
+
- lib/rf_logger/rails/key_value_tagged_logging.rb
|
139
|
+
- lib/rf_logger/rails/rails_compatibility.rb
|
140
|
+
- lib/rf_logger/request/request_headers.rb
|
141
|
+
- lib/rf_logger/request/request_middleware.rb
|
142
|
+
- lib/rf_logger/request/request_tags.rb
|
143
|
+
- lib/rf_logger/rory.rb
|
144
|
+
- lib/rf_logger/rory/initialize_request_middleware.rb
|
145
|
+
- lib/rf_logger/sequel.rb
|
146
|
+
- lib/rf_logger/sequel/base.rb
|
147
|
+
- lib/rf_logger/sequel/logger.rb
|
133
148
|
- lib/rf_logger/simple_logger.rb
|
134
149
|
- lib/rf_logger/version.rb
|
135
150
|
- rf_logger.gemspec
|
151
|
+
- spec/lib/rf_logger/active_record/logger_spec.rb
|
136
152
|
- spec/lib/rf_logger/configuration_spec.rb
|
137
153
|
- spec/lib/rf_logger/log_for_notification_spec.rb
|
138
154
|
- spec/lib/rf_logger/notifications/error_notification_environment_constraints_spec.rb
|
139
155
|
- spec/lib/rf_logger/notifications/error_notification_spec.rb
|
140
|
-
- spec/lib/rf_logger/
|
156
|
+
- spec/lib/rf_logger/rails/rails_compatibility_spec.rb
|
157
|
+
- spec/lib/rf_logger/request/request_headers_spec.rb
|
158
|
+
- spec/lib/rf_logger/request/request_middleware_spec.rb
|
159
|
+
- spec/lib/rf_logger/sequel/logger_spec.rb
|
141
160
|
- spec/lib/rf_logger/simple_logger_spec.rb
|
142
161
|
- spec/lib/rf_logger_spec.rb
|
143
162
|
- spec/spec_helper.rb
|
163
|
+
- spec/support/request_id_shared_examples.rb
|
144
164
|
homepage: ''
|
145
165
|
licenses:
|
146
166
|
- MIT
|
@@ -151,26 +171,32 @@ require_paths:
|
|
151
171
|
- lib
|
152
172
|
required_ruby_version: !ruby/object:Gem::Requirement
|
153
173
|
requirements:
|
154
|
-
- -
|
174
|
+
- - ">="
|
155
175
|
- !ruby/object:Gem::Version
|
156
176
|
version: '0'
|
157
177
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
158
178
|
requirements:
|
159
|
-
- -
|
179
|
+
- - ">="
|
160
180
|
- !ruby/object:Gem::Version
|
161
181
|
version: '0'
|
162
182
|
requirements: []
|
163
183
|
rubyforge_project:
|
164
|
-
rubygems_version: 2.
|
184
|
+
rubygems_version: 2.2.5
|
165
185
|
signing_key:
|
166
186
|
specification_version: 4
|
167
187
|
summary: A logger that adheres to Renewable Funding logging conventions
|
168
188
|
test_files:
|
189
|
+
- spec/lib/rf_logger/active_record/logger_spec.rb
|
169
190
|
- spec/lib/rf_logger/configuration_spec.rb
|
170
191
|
- spec/lib/rf_logger/log_for_notification_spec.rb
|
171
192
|
- spec/lib/rf_logger/notifications/error_notification_environment_constraints_spec.rb
|
172
193
|
- spec/lib/rf_logger/notifications/error_notification_spec.rb
|
173
|
-
- spec/lib/rf_logger/
|
194
|
+
- spec/lib/rf_logger/rails/rails_compatibility_spec.rb
|
195
|
+
- spec/lib/rf_logger/request/request_headers_spec.rb
|
196
|
+
- spec/lib/rf_logger/request/request_middleware_spec.rb
|
197
|
+
- spec/lib/rf_logger/sequel/logger_spec.rb
|
174
198
|
- spec/lib/rf_logger/simple_logger_spec.rb
|
175
199
|
- spec/lib/rf_logger_spec.rb
|
176
200
|
- spec/spec_helper.rb
|
201
|
+
- spec/support/request_id_shared_examples.rb
|
202
|
+
has_rdoc:
|
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
module RfLogger
|
3
|
-
class SequelLogger < Sequel::Model(DB.fetch('select 1'))
|
4
|
-
class << self
|
5
|
-
def inherited(subclass)
|
6
|
-
super
|
7
|
-
subclass.set_dataset underscore(demodulize(subclass.name.pluralize)).to_sym
|
8
|
-
end
|
9
|
-
|
10
|
-
RfLogger::LEVELS.each do |level|
|
11
|
-
define_method level.to_sym do |entry|
|
12
|
-
log = add level, entry
|
13
|
-
|
14
|
-
notification_log = LogForNotification.new(entry.merge(:level => level))
|
15
|
-
ErrorNotification.dispatch_error(notification_log)
|
16
|
-
log
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def add(level, entry)
|
21
|
-
entry[:level] = RfLogger::LEVELS.index(level.to_sym)
|
22
|
-
entry[:actor] = entry[:actor] || ''
|
23
|
-
entry[:metadata] = entry[:metadata] || {}
|
24
|
-
entry[:created_at] = Time.now
|
25
|
-
create(entry)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def metadata
|
30
|
-
JSON.parse(self[:metadata])
|
31
|
-
end
|
32
|
-
|
33
|
-
def metadata=(metadata_hash)
|
34
|
-
self[:metadata] = metadata_hash.to_json
|
35
|
-
end
|
36
|
-
|
37
|
-
def display_level
|
38
|
-
RfLogger::LEVELS[level]
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|