roqua-support 0.1.33 → 0.1.34

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
  SHA256:
3
- metadata.gz: 91c71268f3678a8ff7501d5db547eb5edd6115cf7d403b3383ce3a6c959b0b86
4
- data.tar.gz: 8442d43c71a5185051512d0055118c5607722308a902ce11965dfcfb2de549e3
3
+ metadata.gz: 76f68fbee8a7db03ddae10fbe3d141df7684d51dddf04b31ffe1928afb43c695
4
+ data.tar.gz: 71b36fe4a8d228e2cde4d0650b7fddfa7cf02d32e5020ec30cc4d8249acc2b6b
5
5
  SHA512:
6
- metadata.gz: e97ed287127da20afee3bd07833bc6dc44e4548834518cf0ace7fe39685ace2bdbab4d20810dc51913a8b6d85c32129b590cc7fe45aa897976d50c9cc8565d91
7
- data.tar.gz: a44868fd90c07f751c9b894d636d1c5c32be83d0ce37c81b094e4544439c47bd0e5a36d4a8bd8704b60420d42809785bfde60b4225b31b8dd5cc94686e5ff84c
6
+ metadata.gz: 628059e56300c65b3414e0f66b9cf883a5994cbb9299dd0c19a08d231ebf3de4454aed75383819f4fe812801b88c5ef7c426ba9163883b2b5acd4cd665d48ef3
7
+ data.tar.gz: 02f51d281d67e3c432ab4a5ba5e85ab8a7a89b7ca4851220c71400a2e444c470233c7be97c7f9f5a6f138c0907deb542ddfcb589c6c79eebff0660eea1af9f89
@@ -8,7 +8,7 @@ GIT
8
8
  PATH
9
9
  remote: .
10
10
  specs:
11
- roqua-support (0.1.32)
11
+ roqua-support (0.1.33)
12
12
  active_interaction (~> 3.0)
13
13
  activesupport (>= 3.2, < 6)
14
14
  naught (~> 1.0)
data/README.md CHANGED
@@ -48,6 +48,10 @@ require 'roqua/support/request_logger'
48
48
  Roqua::Support::RequestLogger.attach_to :action_controller
49
49
  ```
50
50
 
51
+ Starting with Rails version 5 and up logging can be redirected to STDOUT by setting the `RAILS_LOG_TO_STDOUT` environment
52
+ variable to a non blank value. roqua-support adds similar functionality by providing an alternative environment variable
53
+ - `RAILS_LOG_TO_STDOUT_USING_ROQUA_LOGGER` - to send the logging output of the custom RoQua logger to STDOUT.
54
+
51
55
  ### Error reporting
52
56
 
53
57
  Log and error to Roqua.logger, appsignal and/or airbrake, depending on which is configured.
@@ -1,5 +1,5 @@
1
1
  module Roqua
2
2
  module Support
3
- VERSION = '0.1.33'.freeze
3
+ VERSION = '0.1.34'.freeze
4
4
  end
5
5
  end
@@ -1,13 +1,25 @@
1
+
1
2
  class RoquaLoggingRailtie < Rails::Railtie
2
- initializer 'roqua_logging_railtie.configure_roqua_logging' do
3
- RoquaLoggingRailtie.configure if ENV['RAILS_LOG_TO_STDOUT_USING_ROQUA_LOGGER'].present?
3
+ config.after_initialize do |app|
4
+ RoquaLoggingRailtie.configure
4
5
  end
5
6
 
6
- def self.configure
7
- Roqua.logger = ActiveSupport::Logger.new(STDOUT)
8
- Roqua.logger.logger.formatter = Logger::Formatter.new
7
+ class << self
8
+ def configure
9
+ Roqua.logger = ActiveSupport::Logger.new(output_stream).tap do |logger|
10
+ logger.formatter = Logger::Formatter.new
11
+ end
12
+
13
+ require 'roqua/support/request_logger'
14
+ Roqua::Support::RequestLogger.attach_to :action_controller
15
+ end
9
16
 
10
- require 'roqua/support/request_logger'
11
- Roqua::Support::RequestLogger.attach_to :action_controller
17
+ def output_stream
18
+ if ENV['RAILS_LOG_TO_STDOUT_USING_ROQUA_LOGGER'].present?
19
+ STDOUT
20
+ else
21
+ Rails.root.join("log/#{Rails.env}-events.log")
22
+ end
23
+ end
12
24
  end
13
25
  end
@@ -16,7 +16,7 @@ module Roqua
16
16
  end
17
17
 
18
18
  def logger
19
- @logger ||= LogWrapper.new(Logger.new(STDOUT))
19
+ @logger || raise('Roqua.logger not yet initialized')
20
20
  end
21
21
 
22
22
  def logger=(logger)
@@ -3,40 +3,40 @@ require 'spec_helper'
3
3
  require 'roqua/support/request_logger'
4
4
  require 'roqua/logging/roqua_logging_railtie'
5
5
 
6
- describe RoquaLoggingRailtie do
7
- let(:initializer_key) { 'roqua_logging_railtie.configure_roqua_logging' }
8
-
9
- subject(:initializer) do
10
- Rails.application.initializers.select { |i| i.name == initializer_key }.first
11
- end
12
-
13
- it 'loads the initializer' do
14
- expect(Rails.application.initializers.map(&:name)).to include(initializer_key)
6
+ RSpec.shared_examples 'RoQua logging setup' do
7
+ def configure_roqua_logging(log_to_stdout)
8
+ ClimateControl.modify RAILS_LOG_TO_STDOUT_USING_ROQUA_LOGGER: log_to_stdout do
9
+ RoquaLoggingRailtie.configure
10
+ end
15
11
  end
16
12
 
17
13
  it 'attaches Roqua::Support::RequestLogger to action_controller' do
18
14
  expect(Roqua::Support::RequestLogger).to receive(:attach_to).with(:action_controller)
19
- RoquaLoggingRailtie.configure
15
+ configure_roqua_logging(log_to_stdout)
20
16
  end
17
+ end
21
18
 
22
- it 'logs to STDOUT' do
23
- RoquaLoggingRailtie.configure
24
- expect(ActiveSupport::Logger.logger_outputs_to?(Roqua.logger.logger, STDOUT)).to be_truthy
25
- end
19
+ Rspec.describe RoquaLoggingRailtie do
20
+ context 'when RAILS_LOG_TO_STDOUT_USING_ROQUA_LOGGER is present' do
21
+ include_examples 'RoQua logging setup'
26
22
 
27
- it 'when RAILS_LOG_TO_STDOUT_USING_ROQUA_LOGGER is blank' do
28
- expect(RoquaLoggingRailtie).to_not receive(:configure)
23
+ let(:log_to_stdout) { 'true' }
29
24
 
30
- ClimateControl.modify RAILS_LOG_TO_STDOUT_USING_ROQUA_LOGGER: '' do
31
- initializer.block.call
25
+ it 'logs to STDOUT' do
26
+ expect(
27
+ ActiveSupport::Logger.logger_outputs_to?(Roqua.logger.logger, STDOUT)
28
+ ).to be_truthy
32
29
  end
33
30
  end
34
31
 
35
- it 'when RAILS_LOG_TO_STDOUT_USING_ROQUA_LOGGER is present' do
36
- expect(RoquaLoggingRailtie).to receive(:configure)
32
+ context 'when RAILS_LOG_TO_STDOUT_USING_ROQUA_LOGGER is blank' do
33
+ include_examples 'RoQua logging setup'
34
+
35
+ let(:log_to_stdout) { '' }
37
36
 
38
- ClimateControl.modify RAILS_LOG_TO_STDOUT_USING_ROQUA_LOGGER: 'true' do
39
- initializer.block.call
37
+ it 'logs to a log file' do
38
+ expect(Roqua.logger.logger.instance_variable_get("@logdev").dev.path)
39
+ .to eql(Rails.root.join('log/test-events.log').to_s)
40
40
  end
41
41
  end
42
42
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roqua-support
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.33
4
+ version: 0.1.34
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marten Veldthuis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-20 00:00:00.000000000 Z
11
+ date: 2018-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_interaction