applicaster-logger 0.8.1 → 0.8.2

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: cc69922a49379e0c1a0bbd5e9be11e23c64addcd
4
- data.tar.gz: 59da5c8c4b595384cccfbcafdc7da227fe493598
3
+ metadata.gz: 06c6c1df0cbe151f198baae8771aa4de6a877c95
4
+ data.tar.gz: '0912c5d269e5e11ffc7326ec37aca0d7bdd38e1a'
5
5
  SHA512:
6
- metadata.gz: 4ccecea471225a37f88924369d974112e3f0fd91e2c190b439e9c915eb4ea048d9c10a297356cd1c7d74f0dee9472038ff6b08576e2b3c2e811dd65a4cecd17b
7
- data.tar.gz: f2c1fa38d22ddca0f3f1782eda2ed619de07f7eb158510042d3eb3768b5a88353315aefafd1407c57fea44df5fbce19f1cae2dfa4abe5951c7feaa0dd00b7a8d
6
+ metadata.gz: e4cedea62aaf6ecdbe55f148e5a4020c9fad52485afad5fdd860176911c3e1c0465595a3d17041f6a00dbbbb9066b2d66dad9f850458ace5a5d0f01bb1cd7823
7
+ data.tar.gz: b2cb47a65c1e3b3877cad7bac8afde10d29835536f9e8a9c2d33b37e3cd6bac71260baa07daedf1848a0e99ee5d23b8cfc46e6d91305b2e1c9666ff69c16a407
@@ -6,18 +6,20 @@ require_relative "./lograge/formatter"
6
6
  module Applicaster
7
7
  module Logger
8
8
  class Railtie < Rails::Railtie
9
- DEFAULT_APP_NAME = Rails.application.class.parent.to_s.underscore
9
+ DEFAULT_APP_NAME = proc { Rails.application.class.parent.to_s.underscore }
10
10
 
11
11
  # taken from https://github.com/rails/rails/blob/master/actionpack/lib/action_controller/log_subscriber.rb
12
12
  INTERNAL_PARAMS = %w(controller action format only_path)
13
13
 
14
- config.applicaster_logger = ActiveSupport::OrderedOptions.new.tap do |config|
15
- uri = ENV["LOGSTASH_URI"]
16
- config.enabled = uri.present?
17
- config.level = ::Logger::INFO
18
- config.application_name = ENV.fetch("LOG_APP_NAME") { DEFAULT_APP_NAME }
19
- config.logstash_config = uri.present? ? { uri: uri } : { type: :stdout }
20
- config.logzio_token = ENV['LOGZIO_TOKEN'].presence
14
+ ActiveSupport.on_load(:before_configuration) do
15
+ config.applicaster_logger = ActiveSupport::OrderedOptions.new.tap do |config|
16
+ uri = ENV["LOGSTASH_URI"]
17
+ config.enabled = uri.present?
18
+ config.level = ::Logger::INFO
19
+ config.application_name = ENV.fetch("LOG_APP_NAME", &DEFAULT_APP_NAME)
20
+ config.logstash_config = uri.present? ? Railtie.uri_logstash_config(uri) : { type: :stdout }
21
+ config.logzio_token = ENV['LOGZIO_TOKEN'].presence
22
+ end
21
23
  end
22
24
 
23
25
  initializer :applicaster_logger_rack do |app|
@@ -33,6 +35,14 @@ module Applicaster
33
35
  setup_logger(app) if app.config.applicaster_logger.enabled
34
36
  end
35
37
 
38
+ def self.uri_logstash_config(uri)
39
+ parsed = ::URI.parse(uri)
40
+ # params parsing can be removed if this is merged:
41
+ # https://github.com/dwbutler/logstash-logger/pull/148
42
+ params = Hash[CGI.parse(parsed.query.to_s).map {|k,v| [k,v.first]}]
43
+ { uri: uri, buffer_max_items: Integer(params["buffer_max_items"] || 1000)}
44
+ end
45
+
36
46
  def setup_lograge(app)
37
47
  app.config.lograge.enabled = true
38
48
  app.config.lograge.formatter = Applicaster::Logger::Lograge::Formatter.new
@@ -1,5 +1,5 @@
1
1
  module Applicaster
2
2
  module Logger
3
- VERSION = "0.8.1"
3
+ VERSION = "0.8.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: applicaster-logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vitaly Gorodetsky
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-18 00:00:00.000000000 Z
11
+ date: 2018-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logstash-logger