logstasher 0.8.6 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/logstasher.rb +6 -6
- data/lib/logstasher/action_view/log_subscriber.rb +0 -1
- data/lib/logstasher/active_record/log_subscriber.rb +0 -2
- data/lib/logstasher/active_support/log_subscriber.rb +0 -1
- data/lib/logstasher/railtie.rb +39 -0
- data/lib/logstasher/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: 91e7c9a0ab40af2e0f9e71ea61fde24dfc2dfd9d
|
4
|
+
data.tar.gz: 4a89eb5bcf8cba52d1ae269ffc00cf9df733211c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 055f322b5f2abdab76f784844970691e7845cc3e216f4f37f35a79f61192049c3ced249b6eed9b8477c3c776c81bbba52ff7f0ac0c29652eabdedfee2541f332
|
7
|
+
data.tar.gz: 3076cb4c8bf1e8e8dc0cefaa348f6ca7350d36b984cf01da6ee7b57ce92d697ca1f141b6406b15f5034a025ed5cff405f7f242f9c205c3e32fda9e4b88f68162
|
data/lib/logstasher.rb
CHANGED
@@ -14,7 +14,7 @@ module LogStasher
|
|
14
14
|
STORE_KEY = :logstasher_data
|
15
15
|
REQUEST_CONTEXT_KEY = :logstasher_request_context
|
16
16
|
|
17
|
-
attr_accessor :logger, :logger_path, :enabled, :log_controller_parameters, :source, :backtrace,
|
17
|
+
attr_accessor :logger, :logger_path, :enabled, :log_controller_parameters, :source, :backtrace,
|
18
18
|
:controller_monkey_patch
|
19
19
|
# Setting the default to 'unknown' to define the default behaviour
|
20
20
|
@source = 'unknown'
|
@@ -87,15 +87,15 @@ module LogStasher
|
|
87
87
|
def setup_before(config)
|
88
88
|
require 'logstash-event'
|
89
89
|
self.enabled = config.enabled
|
90
|
-
LogStasher::ActiveSupport::LogSubscriber.attach_to :action_controller
|
91
|
-
LogStasher::ActiveSupport::MailerLogSubscriber.attach_to :action_mailer
|
92
|
-
LogStasher::ActiveRecord::LogSubscriber.attach_to :active_record
|
93
|
-
LogStasher::ActionView::LogSubscriber.attach_to :action_view
|
90
|
+
LogStasher::ActiveSupport::LogSubscriber.attach_to :action_controller if config.controller_enabled
|
91
|
+
LogStasher::ActiveSupport::MailerLogSubscriber.attach_to :action_mailer if config.mailer_enabled
|
92
|
+
LogStasher::ActiveRecord::LogSubscriber.attach_to :active_record if config.record_enabled
|
93
|
+
LogStasher::ActionView::LogSubscriber.attach_to :action_view if config.view_enabled
|
94
94
|
end
|
95
95
|
|
96
96
|
def setup(config)
|
97
97
|
# Path instrumentation class to insert our hook
|
98
|
-
if (! config.controller_monkey_patch && config.controller_monkey_patch != false) || config.controller_monkey_patch == true
|
98
|
+
if (! config.controller_monkey_patch && config.controller_monkey_patch != false) || config.controller_monkey_patch == true
|
99
99
|
require 'logstasher/rails_ext/action_controller/metal/instrumentation'
|
100
100
|
end
|
101
101
|
self.suppress_app_logs(config)
|
@@ -21,7 +21,6 @@ module LogStasher
|
|
21
21
|
def logstash_event(event)
|
22
22
|
data = event.payload
|
23
23
|
|
24
|
-
return unless logger.debug?
|
25
24
|
return if 'SCHEMA' == data[:name]
|
26
25
|
|
27
26
|
data.merge! runtimes(event)
|
@@ -52,7 +51,6 @@ module LogStasher
|
|
52
51
|
|
53
52
|
def extract_custom_fields(data)
|
54
53
|
custom_fields = (!LogStasher.custom_fields.empty? && data.extract!(*LogStasher.custom_fields)) || {}
|
55
|
-
LogStasher.custom_fields.clear
|
56
54
|
custom_fields
|
57
55
|
end
|
58
56
|
end
|
data/lib/logstasher/railtie.rb
CHANGED
@@ -1,13 +1,34 @@
|
|
1
1
|
require 'rails/railtie'
|
2
2
|
require 'action_view/log_subscriber'
|
3
3
|
require 'action_controller/log_subscriber'
|
4
|
+
require 'socket'
|
4
5
|
|
5
6
|
module LogStasher
|
6
7
|
class Railtie < Rails::Railtie
|
7
8
|
config.logstasher = ::ActiveSupport::OrderedOptions.new
|
8
9
|
config.logstasher.enabled = false
|
9
10
|
|
11
|
+
# Set up the default logging options
|
12
|
+
config.logstasher.controller_enabled = true
|
13
|
+
config.logstasher.mailer_enabled = true
|
14
|
+
config.logstasher.record_enabled = false
|
15
|
+
config.logstasher.view_enabled = true
|
16
|
+
|
17
|
+
# Try loading the config/logstasher.yml if present
|
18
|
+
env = Rails.env.to_sym || :development
|
19
|
+
config_file = File.expand_path "./config/logstasher.yml"
|
20
|
+
|
21
|
+
# Load and ERB templating of YAML files
|
22
|
+
LOGSTASHER = File.exists?(config_file) ? YAML.load(ERB.new(File.read(config_file)).result).symbolize_keys : nil
|
23
|
+
|
10
24
|
initializer :logstasher, :before => :load_config_initializers do |app|
|
25
|
+
if LOGSTASHER.present?
|
26
|
+
# process common configs
|
27
|
+
LogStasher.process_config(app.config.logstasher, LOGSTASHER)
|
28
|
+
# process environment specific configs
|
29
|
+
LogStasher.process_config(app.config.logstasher, LOGSTASHER[env].symbolize_keys) if LOGSTASHER.key? env
|
30
|
+
end
|
31
|
+
|
11
32
|
app.config.action_dispatch.rack_cache[:verbose] = false if app.config.action_dispatch.rack_cache
|
12
33
|
LogStasher.setup_before(app.config.logstasher) if app.config.logstasher.enabled
|
13
34
|
end
|
@@ -18,4 +39,22 @@ module LogStasher
|
|
18
39
|
end
|
19
40
|
end
|
20
41
|
end
|
42
|
+
|
43
|
+
def process_config(config, yml_config)
|
44
|
+
# Enable the logstasher logs for the current environment
|
45
|
+
config.enabled = yml_config[:enabled] if yml_config.key? :enabled
|
46
|
+
config.controller_enabled = yml_config[:controller_enabled] if yml_config.key? :controller_enabled
|
47
|
+
config.mailer_enabled = yml_config[:mailer_enabled] if yml_config.key? :mailer_enabled
|
48
|
+
config.record_enabled = yml_config[:record_enabled] if yml_config.key? :record_enabled
|
49
|
+
config.view_enabled = yml_config[:view_enabled] if yml_config.key? :view_enabled
|
50
|
+
#
|
51
|
+
# # This line is optional if you do not want to suppress app logs in your <environment>.log
|
52
|
+
config.suppress_app_log = yml_config[:suppress_app_log] if yml_config.key? :suppress_app_log
|
53
|
+
#
|
54
|
+
# # This line is optional, it allows you to set a custom value for the @source field of the log event
|
55
|
+
config.source = yml_config[:source].present? ? yml_config[:source] : IPSocket.getaddress(Socket.gethostname)
|
56
|
+
|
57
|
+
config.backtrace = yml_config[:backtrace] if yml_config.key? :backtrace
|
58
|
+
config.logger_path = yml_config[:logger_path] if yml_config.key? :logger_path
|
59
|
+
end
|
21
60
|
end
|
data/lib/logstasher/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstasher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shadab Ahmed
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logstash-event
|