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 +4 -4
- data/lib/applicaster/logger/railtie.rb +18 -8
- data/lib/applicaster/logger/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06c6c1df0cbe151f198baae8771aa4de6a877c95
|
4
|
+
data.tar.gz: '0912c5d269e5e11ffc7326ec37aca0d7bdd38e1a'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
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.
|
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-
|
11
|
+
date: 2018-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logstash-logger
|