Browse files

The logstash-event gem should only be required when necessary.

This means, users of the logstash output format have to install the gem on
their own. The upside is, that we still don't require the additional gem
for setups using only the lograge output.
  • Loading branch information...
1 parent 818cdcc commit 04160bf923950f4f34e5eae8884ee49c54120988 @meineerde meineerde committed Nov 13, 2012
Showing with 14 additions and 3 deletions.
  1. +1 −0 Gemfile
  2. +7 −0 README.md
  3. +6 −2 lib/lograge.rb
  4. +0 −1 lograge.gemspec
View
1 Gemfile
@@ -5,4 +5,5 @@ gemspec
group :test do
gem 'actionpack'
+ gem 'logstash-event'
end
View
7 README.md
@@ -86,6 +86,13 @@ MyApp::Application.configure do
end
```
+*Note:* When using the logstash output, you need to add the additional gem
+`logstash-event`. You can simply add it to your Gemfile like this
+
+```ruby
+gem "logstash-event"
+```
+
Done.
**Internals**
View
8 lib/lograge.rb
@@ -63,8 +63,12 @@ def self.setup(app)
Lograge.log_format = app.config.lograge.log_format || :lograge
case Lograge.log_format.to_s
when "logstash"
- # Use the gem for creating Logstash events
- require "logstash-event"
+ begin
+ require "logstash-event"
+ rescue LoadError
+ puts "You need to install the logstash-event gem to use the logstash output."
+ raise
+ end
end
end
end
View
1 lograge.gemspec
@@ -23,5 +23,4 @@ Gem::Specification.new do |s|
s.add_development_dependency "guard-rspec"
s.add_runtime_dependency "activesupport"
s.add_runtime_dependency "actionpack"
- s.add_runtime_dependency "logstash-event"
end

0 comments on commit 04160bf

Please sign in to comment.