logstasher 0.2.5 → 0.2.8

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.
data/README.md CHANGED
@@ -55,8 +55,8 @@ In your Gemfile:
55
55
  # Enable the logstasher logs for the current environment
56
56
  config.logstasher.enabled = true
57
57
 
58
- # This line is optional if you do not want to supress app logs in your <environment>.log
59
- config.logstasher.supress_app_log = false
58
+ # This line is optional if you do not want to suppress app logs in your <environment>.log
59
+ config.logstasher.suppress_app_log = false
60
60
 
61
61
  ## Adding custom fields to the log
62
62
 
@@ -66,6 +66,8 @@ Since some fields are very specific to your application for e.g. *user_name*, so
66
66
 
67
67
  if LogStasher.enabled
68
68
  LogStasher.add_custom_fields do |fields|
69
+ # This block is run in application_controller context,
70
+ # so you have access to all controller methods
69
71
  fields[:user] = current_user && current_user.mail
70
72
  fields[:site] = request.path =~ /^\/api/ ? 'api' : 'user'
71
73
 
data/lib/logstasher.rb CHANGED
@@ -56,12 +56,17 @@ module LogStasher
56
56
  end
57
57
 
58
58
  def self.suppress_app_logs(app)
59
- if app.config.logstasher.supress_app_log.nil? || app.config.logstasher.supress_app_log
59
+ if configured_to_suppress_app_logs?(app)
60
60
  require 'logstasher/rails_ext/rack/logger'
61
61
  LogStasher.remove_existing_log_subscriptions
62
62
  end
63
63
  end
64
64
 
65
+ def self.configured_to_suppress_app_logs?(app)
66
+ # This supports both spellings: "suppress_app_log" and "supress_app_log"
67
+ !!(app.config.logstasher.suppress_app_log.nil? ? app.config.logstasher.supress_app_log : app.config.logstasher.suppress_app_log)
68
+ end
69
+
65
70
  def self.custom_fields
66
71
  Thread.current[:logstasher_custom_fields] ||= []
67
72
  end
@@ -1,3 +1,3 @@
1
1
  module LogStasher
2
- VERSION = "0.2.5"
2
+ VERSION = "0.2.8"
3
3
  end
@@ -77,14 +77,32 @@ describe LogStasher do
77
77
  end
78
78
  end
79
79
 
80
- describe '.supress_app_logs' do
81
- let(:logstasher_config){ mock(:logstasher => mock(:supress_app_log => true))}
80
+ describe '.suppress_app_logs' do
81
+ let(:logstasher_config){ mock(:logstasher => mock(:suppress_app_log => true))}
82
82
  let(:app){ mock(:config => logstasher_config)}
83
83
  it 'removes existing subscription if enabled' do
84
84
  LogStasher.should_receive(:require).with('logstasher/rails_ext/rack/logger')
85
85
  LogStasher.should_receive(:remove_existing_log_subscriptions)
86
86
  LogStasher.suppress_app_logs(app)
87
87
  end
88
+
89
+ context 'when disabled' do
90
+ let(:logstasher_config){ mock(:logstasher => mock(:suppress_app_log => false)) }
91
+ it 'does not remove existing subscription' do
92
+ LogStasher.should_not_receive(:remove_existing_log_subscriptions)
93
+ LogStasher.suppress_app_logs(app)
94
+ end
95
+
96
+ describe "backward compatibility" do
97
+ context 'with spelling "supress_app_log"' do
98
+ let(:logstasher_config){ mock(:logstasher => mock(:suppress_app_log => nil, :supress_app_log => false)) }
99
+ it 'does not remove existing subscription' do
100
+ LogStasher.should_not_receive(:remove_existing_log_subscriptions)
101
+ LogStasher.suppress_app_logs(app)
102
+ end
103
+ end
104
+ end
105
+ end
88
106
  end
89
107
 
90
108
  describe '.appended_params' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstasher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-07 00:00:00.000000000 Z
12
+ date: 2013-08-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: logstash-event
@@ -113,7 +113,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
113
113
  version: '0'
114
114
  segments:
115
115
  - 0
116
- hash: 66757699131384912
116
+ hash: -3954603627372273553
117
117
  required_rubygems_version: !ruby/object:Gem::Requirement
118
118
  none: false
119
119
  requirements:
@@ -122,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
122
  version: '0'
123
123
  segments:
124
124
  - 0
125
- hash: 66757699131384912
125
+ hash: -3954603627372273553
126
126
  requirements: []
127
127
  rubyforge_project: logstasher
128
128
  rubygems_version: 1.8.25