europeana-logging 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c45b72b59da3a04c902f31739286925c72068302
4
- data.tar.gz: 137fd448d51e60037acc59a985dd519b5936c4ba
3
+ metadata.gz: d28b719bb19c0365a3b0710aebf3034c24b40c97
4
+ data.tar.gz: 5e44dc017d5952ec6d80d8fd5879014702dd412e
5
5
  SHA512:
6
- metadata.gz: 39fd72516044376f1bdf2ae59f543e0b6dae84bd0c0d40e9ded663fb70465a941ee948eb544c0c59f05fd3d902a169ddfb0971c268af2aca7e10f9686656a532
7
- data.tar.gz: f6df585edc39903cc8a3383add97585a512128cb81c93f56458faab0394fc904e48429270b4657de30a4daac0a7eb2d6535b1549f21a08dbe876cc1ddbcc1b3e
6
+ metadata.gz: eedfafe46cedcf2b2de0947187239a77e7de7c8779e3a6062e561b2176f4ae884433cdcf9367c746604ccd5615dfe9e3e181759991c5a05be9d961a513699cb2
7
+ data.tar.gz: 490c3252fe06dbb2855a2b4803ded14750c1fe681d46d69b1b5751777782346ffc1298f0a301ac44f3c66c212c09adb97e7c7eaada4eefa80dc5453bf4dbf36c
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+ module Europeana
3
+ module Logging
4
+ module LogSessionId
5
+ extend ActiveSupport::Concern
6
+
7
+ ##
8
+ # Overrides `#logger` in controller to first set session via
9
+ # `Europeana::Logging::SessionLogging#session=`
10
+ def logger(*args)
11
+ super.session_id = session.id unless @_request.nil?
12
+ super(*args)
13
+ end
14
+
15
+ ##
16
+ # Lograge payload
17
+ def append_info_to_payload(payload)
18
+ super
19
+ payload[:session_id] = session.id
20
+ end
21
+ end
22
+ end
23
+ end
@@ -12,8 +12,6 @@ module Europeana
12
12
 
13
13
  # Configure lograge
14
14
  initializer 'europeana_logging.configure_lograge' do |app|
15
- ApplicationController.send :include, Europeana::Logging::LogragePayload
16
-
17
15
  app.config.lograge.custom_options = lambda do |event|
18
16
  {}.tap do |custom|
19
17
  if event.payload.key?(:redis_runtime)
@@ -29,9 +27,7 @@ module Europeana
29
27
  end
30
28
 
31
29
  # Configure Logstash
32
- initializer 'europeana_logging.configure_logstash' do |app|
33
- stdout_logger = LogStashLogger.new(type: :stdout)
34
- app.config.logger = Rails.logger = ActionController::Base.logger = stdout_logger
30
+ initializer 'europeana_logging.configure_logstash' do |_app|
35
31
  LogStashLogger.configure do |config|
36
32
  config.customize_event do |event|
37
33
  event['level'] = event.remove('severity')
@@ -39,6 +35,21 @@ module Europeana
39
35
  end
40
36
  end
41
37
  end
38
+
39
+ # Init app loggers
40
+ initializer 'europeana_logging.set_app_loggers' do |app|
41
+ app.config.logger = LogStashLogger.new(type: :stdout)
42
+
43
+ Rails.logger = LogStashLogger.new(type: :stdout)
44
+
45
+ ActionController::Base.logger = LogStashLogger.new(type: :stdout)
46
+ ActionController::Base.logger.extend(Europeana::Logging::SessionLogging)
47
+ end
48
+
49
+ # Controller concern for session ID logging
50
+ initializer 'europeana_logging.application_controller_log_session_id' do |_app|
51
+ ApplicationController.send :include, Europeana::Logging::LogSessionId
52
+ end
42
53
  end
43
54
  end
44
55
  end
@@ -0,0 +1,16 @@
1
+ module Europeana
2
+ module Logging
3
+ module SessionLogging
4
+ attr_accessor :session_id
5
+
6
+ %w(unknown fatal error warn info debug).each do |level|
7
+ define_method level.to_sym do |message=nil|
8
+ message = yield if message.nil? && block_given?
9
+ hmessage = message.is_a?(Hash) ? message.dup : { message: message }
10
+ hmessage[:session_id] = session_id
11
+ super(hmessage)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module Europeana
3
3
  module Logging
4
- VERSION = '0.2.2'
4
+ VERSION = '0.2.3'
5
5
  end
6
6
  end
@@ -3,5 +3,6 @@ require 'europeana/logging/engine'
3
3
 
4
4
  module Europeana
5
5
  module Logging
6
+ autoload :SessionLogging, 'europeana/logging/session_logging'
6
7
  end
7
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: europeana-logging
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Doe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-15 00:00:00.000000000 Z
11
+ date: 2017-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -82,9 +82,10 @@ files:
82
82
  - LICENSE.md
83
83
  - README.md
84
84
  - Rakefile
85
- - app/controllers/concerns/europeana/logging/lograge_payload.rb
85
+ - app/controllers/concerns/europeana/logging/log_session_id.rb
86
86
  - lib/europeana/logging.rb
87
87
  - lib/europeana/logging/engine.rb
88
+ - lib/europeana/logging/session_logging.rb
88
89
  - lib/europeana/logging/version.rb
89
90
  - test/dummy/README.rdoc
90
91
  - test/dummy/Rakefile
@@ -115,7 +116,6 @@ files:
115
116
  - test/dummy/config/locales/en.yml
116
117
  - test/dummy/config/routes.rb
117
118
  - test/dummy/config/secrets.yml
118
- - test/dummy/log/test.log
119
119
  - test/dummy/public/404.html
120
120
  - test/dummy/public/422.html
121
121
  - test/dummy/public/500.html
@@ -149,39 +149,38 @@ specification_version: 4
149
149
  summary: Europeana logging
150
150
  test_files:
151
151
  - test/integration/navigation_test.rb
152
- - test/test_helper.rb
153
- - test/europeana/logging_test.rb
154
- - test/dummy/config.ru
155
- - test/dummy/app/helpers/application_helper.rb
156
- - test/dummy/app/views/layouts/application.html.erb
157
- - test/dummy/app/controllers/application_controller.rb
158
- - test/dummy/app/assets/javascripts/application.js
159
- - test/dummy/app/assets/stylesheets/application.css
160
- - test/dummy/log/test.log
161
- - test/dummy/public/favicon.ico
162
152
  - test/dummy/public/404.html
163
- - test/dummy/public/422.html
164
153
  - test/dummy/public/500.html
154
+ - test/dummy/public/favicon.ico
155
+ - test/dummy/public/422.html
165
156
  - test/dummy/config/locales/en.yml
157
+ - test/dummy/config/application.rb
166
158
  - test/dummy/config/routes.rb
167
- - test/dummy/config/secrets.yml
168
- - test/dummy/config/initializers/assets.rb
169
- - test/dummy/config/initializers/cookies_serializer.rb
170
- - test/dummy/config/initializers/backtrace_silencers.rb
171
- - test/dummy/config/initializers/inflections.rb
172
- - test/dummy/config/initializers/mime_types.rb
173
- - test/dummy/config/initializers/filter_parameter_logging.rb
174
- - test/dummy/config/initializers/wrap_parameters.rb
175
- - test/dummy/config/initializers/session_store.rb
176
159
  - test/dummy/config/environments/development.rb
177
160
  - test/dummy/config/environments/production.rb
178
161
  - test/dummy/config/environments/test.rb
179
- - test/dummy/config/application.rb
180
- - test/dummy/config/environment.rb
162
+ - test/dummy/config/secrets.yml
181
163
  - test/dummy/config/boot.rb
164
+ - test/dummy/config/environment.rb
165
+ - test/dummy/config/initializers/mime_types.rb
166
+ - test/dummy/config/initializers/wrap_parameters.rb
167
+ - test/dummy/config/initializers/backtrace_silencers.rb
168
+ - test/dummy/config/initializers/filter_parameter_logging.rb
169
+ - test/dummy/config/initializers/session_store.rb
170
+ - test/dummy/config/initializers/assets.rb
171
+ - test/dummy/config/initializers/cookies_serializer.rb
172
+ - test/dummy/config/initializers/inflections.rb
173
+ - test/dummy/app/controllers/application_controller.rb
174
+ - test/dummy/app/assets/stylesheets/application.css
175
+ - test/dummy/app/assets/javascripts/application.js
176
+ - test/dummy/app/helpers/application_helper.rb
177
+ - test/dummy/app/views/layouts/application.html.erb
178
+ - test/dummy/config.ru
182
179
  - test/dummy/Rakefile
183
- - test/dummy/bin/rails
184
180
  - test/dummy/bin/rake
185
181
  - test/dummy/bin/bundle
186
182
  - test/dummy/bin/setup
183
+ - test/dummy/bin/rails
187
184
  - test/dummy/README.rdoc
185
+ - test/europeana/logging_test.rb
186
+ - test/test_helper.rb
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
- module Europeana
3
- module Logging
4
- module LogragePayload
5
- extend ActiveSupport::Concern
6
-
7
- def append_info_to_payload(payload)
8
- super
9
- payload[:session_id] = session.id
10
- end
11
- end
12
- end
13
- end
@@ -1,6 +0,0 @@
1
- ----------------------------------
2
- Europeana::LoggingTest: test_truth
3
- ----------------------------------
4
- ----------------------------------
5
- Europeana::LoggingTest: test_truth
6
- ----------------------------------