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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +4 -0
- data/lib/roqua-support/version.rb +1 -1
- data/lib/roqua/logging/roqua_logging_railtie.rb +19 -7
- data/lib/roqua/support.rb +1 -1
- data/spec/roqua/logging/roqua_logging_railtie_spec.rb +22 -22
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76f68fbee8a7db03ddae10fbe3d141df7684d51dddf04b31ffe1928afb43c695
|
4
|
+
data.tar.gz: 71b36fe4a8d228e2cde4d0650b7fddfa7cf02d32e5020ec30cc4d8249acc2b6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 628059e56300c65b3414e0f66b9cf883a5994cbb9299dd0c19a08d231ebf3de4454aed75383819f4fe812801b88c5ef7c426ba9163883b2b5acd4cd665d48ef3
|
7
|
+
data.tar.gz: 02f51d281d67e3c432ab4a5ba5e85ab8a7a89b7ca4851220c71400a2e444c470233c7be97c7f9f5a6f138c0907deb542ddfcb589c6c79eebff0660eea1af9f89
|
data/Gemfile.lock
CHANGED
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,13 +1,25 @@
|
|
1
|
+
|
1
2
|
class RoquaLoggingRailtie < Rails::Railtie
|
2
|
-
|
3
|
-
RoquaLoggingRailtie.configure
|
3
|
+
config.after_initialize do |app|
|
4
|
+
RoquaLoggingRailtie.configure
|
4
5
|
end
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
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
|
-
|
11
|
-
|
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
|
data/lib/roqua/support.rb
CHANGED
@@ -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
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
-
|
15
|
+
configure_roqua_logging(log_to_stdout)
|
20
16
|
end
|
17
|
+
end
|
21
18
|
|
22
|
-
|
23
|
-
|
24
|
-
|
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
|
-
|
28
|
-
expect(RoquaLoggingRailtie).to_not receive(:configure)
|
23
|
+
let(:log_to_stdout) { 'true' }
|
29
24
|
|
30
|
-
|
31
|
-
|
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
|
-
|
36
|
-
|
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
|
-
|
39
|
-
|
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.
|
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-
|
11
|
+
date: 2018-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_interaction
|