production_toolkit 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 03edd853f8bf444fcc2f5bbdc29b18456156fb3d
4
- data.tar.gz: c8717d97f7a7088405f0abf4df6f3d1eca311052
3
+ metadata.gz: 3e77464062df65025da56cb9584de5ee15e63b80
4
+ data.tar.gz: 11425cb2e26b72195f88dd573543fe175b834b2c
5
5
  SHA512:
6
- metadata.gz: 607e708a8d6c9917cce81274d536f9c38561bde53dd89c1f0e37dba6b807ab501d31d2d9edf23eb2bc457b4ed3e7ac5fa00bc083541d1fdd7cab0ba61249ab94
7
- data.tar.gz: e5eaf266eac7c499345c9899689198ef6c383bf52f4064829a0742b4c56fc9e9716efacb563ba093cbddddcfbbe03689e65cf7066cd7960c11a4b1f811833299
6
+ metadata.gz: 2488dd1b231b59c4698ee6794cba4d4eff3dcac675bbbf15f03df950c72daf5552953794c6fd940d3567bb9eba9b6d0a493485457a82da341346e86622bd533e
7
+ data.tar.gz: fc4424def77ce1b1d332beae37d084402b53948dae4a81d596035aade7e48af109335f665550bfdfa8f97b11caf9e405101c3a9ad49377e81596ad78e10563af
@@ -0,0 +1,5 @@
1
+ ## Production Toolkit 0.1.3 ##
2
+
3
+ * Ignore ActionController::RoutingError in rollbar
4
+ * Read the log_level from Rails or default to info
5
+ * Extract rollbar configuration so not rails dependent
data/README.md CHANGED
@@ -33,3 +33,13 @@ require 'production_toolkit'
33
33
 
34
34
  For examples on most usage see the tests in the spec directory.
35
35
  As these contain many basic examples with expected output.
36
+
37
+ ## Log level
38
+
39
+ When using the 'le' gem, production_toolkit will set the log level to the one defined in the application's production.rb (for version >= 0.1.3).
40
+
41
+ ```ruby
42
+ config.log_level = :warn
43
+ ```
44
+
45
+ If a log level is not defined by the app, the logger will default to 'info' level logging.
@@ -2,6 +2,7 @@ if defined?(Rails)
2
2
  if Rails.env.production?
3
3
  require 'le'
4
4
  log_entries_key = Rails.application.secrets.log_entries_key
5
- Rails.logger = Le.new(log_entries_key, ssl: true, tag: true)
5
+ log_level = Rails.application.config.log_level || :info
6
+ Rails.logger = Le.new(log_entries_key, ssl: true, tag: true, log_level: log_level)
6
7
  end
7
8
  end
@@ -1,60 +1,12 @@
1
- class RollbarConfig
2
- attr_reader :server_token, :client_token, :environment
1
+ require 'rollbar_configuator'
3
2
 
4
- def initialize(config)
5
- @enabled = config.fetch(:enabled, false)
6
- if enabled?
7
- @server_token = config.fetch(:server_token)
8
- @client_token = config.fetch(:client_token)
9
- @environment = config.fetch(:environment)
10
- end
11
- end
3
+ if defined?(Rails)
4
+ config = Rails.application.secrets.rollbar
12
5
 
13
- def enabled?
14
- @enabled
15
- end
16
- end
6
+ if config
7
+ configurator = RollbarConfigurator.new(config)
8
+ configurator.configure
17
9
 
18
- class RollbarConfigurator
19
- ERROR_MESSAGE = 'rollbar not defined in secrets.yml'
20
-
21
- def initialize(configuration)
22
- @configuration = configuration
23
- end
24
-
25
- def configure
26
- notify_missing_configuration! unless @configuration.present?
27
- configure_rollbar
28
- end
29
-
30
- def rollbar_config
31
- @rollbar_config ||= RollbarConfig.new(@configuration.symbolize_keys)
32
- end
33
-
34
- private
35
-
36
- def configure_rollbar
37
- return unless rollbar_config.enabled?
38
-
39
- require 'rollbar'
40
-
41
- ::Rollbar.configure do |config|
42
- config.enabled = true
43
- config.access_token = rollbar_config.server_token
44
- config.environment = rollbar_config.environment
45
- config.exception_level_filters.merge!('ActionController::RoutingError' => 'ignore')
46
- end
47
- end
48
-
49
- def notify_missing_configuration!
50
- fail ERROR_MESSAGE
10
+ Rails.application.config.rollbar = configurator.rollbar_config
51
11
  end
52
12
  end
53
-
54
- config = if defined?(Rails)
55
- Rails.application.secrets.rollbar
56
- end
57
- configurator = RollbarConfigurator.new(config)
58
- configurator.configure
59
-
60
- Rails.application.config.rollbar = configurator.rollbar_config if defined?(Rails)
@@ -0,0 +1,54 @@
1
+ require 'facets/hash/symbolize_keys'
2
+
3
+ class RollbarConfig
4
+ attr_reader :server_token, :client_token, :environment
5
+
6
+ def initialize(config)
7
+ @enabled = config.fetch(:enabled, false)
8
+ if enabled?
9
+ @server_token = config.fetch(:server_token)
10
+ @client_token = config.fetch(:client_token)
11
+ @environment = config.fetch(:environment)
12
+ end
13
+ end
14
+
15
+ def enabled?
16
+ @enabled
17
+ end
18
+ end
19
+
20
+ class RollbarConfigurator
21
+ ERROR_MESSAGE = 'rollbar not defined in secrets.yml'
22
+
23
+ def initialize(configuration)
24
+ @configuration = configuration
25
+ end
26
+
27
+ def configure
28
+ notify_missing_configuration! unless @configuration.present?
29
+ configure_rollbar
30
+ end
31
+
32
+ def rollbar_config
33
+ @rollbar_config ||= RollbarConfig.new(@configuration.symbolize_keys)
34
+ end
35
+
36
+ private
37
+
38
+ def configure_rollbar
39
+ return unless rollbar_config.enabled?
40
+
41
+ require 'rollbar'
42
+
43
+ ::Rollbar.configure do |config|
44
+ config.enabled = true
45
+ config.access_token = rollbar_config.server_token
46
+ config.environment = rollbar_config.environment
47
+ config.exception_level_filters.merge!('ActionController::RoutingError' => 'ignore')
48
+ end
49
+ end
50
+
51
+ def notify_missing_configuration!
52
+ fail ERROR_MESSAGE
53
+ end
54
+ end
@@ -1,3 +1,3 @@
1
1
  module ProductionToolkit
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: production_toolkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Noack
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-26 00:00:00.000000000 Z
11
+ date: 2016-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rollbar
@@ -228,6 +228,7 @@ extensions: []
228
228
  extra_rdoc_files: []
229
229
  files:
230
230
  - ".gitignore"
231
+ - CHANGELOG.md
231
232
  - Gemfile
232
233
  - README.md
233
234
  - Rakefile
@@ -236,6 +237,7 @@ files:
236
237
  - lib/production_toolkit/initializers/lograge.rb
237
238
  - lib/production_toolkit/initializers/rollbar.rb
238
239
  - lib/production_toolkit/railtie.rb
240
+ - lib/production_toolkit/rollbar_configurator.rb
239
241
  - lib/production_toolkit/version.rb
240
242
  - production_toolkit.gemspec
241
243
  homepage: http://github.com/sealink/production_toolkit
@@ -258,7 +260,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
258
260
  version: '0'
259
261
  requirements: []
260
262
  rubyforge_project:
261
- rubygems_version: 2.4.5.1
263
+ rubygems_version: 2.4.8
262
264
  signing_key:
263
265
  specification_version: 4
264
266
  summary: Integrate production gems for high quality projects.