Class: Graylog2Rails::Notifier
- Inherits:
-
Object
- Object
- Graylog2Rails::Notifier
- Defined in:
- lib/graylog2-rails/notifier.rb
Instance Attribute Summary collapse
-
#gelf ⇒ Object
readonly
Returns the value of attribute gelf.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ Notifier
constructor
A new instance of Notifier.
Constructor Details
#initialize(args = {}) ⇒ Notifier
Returns a new instance of Notifier.
5 6 7 8 9 10 11 12 13 |
# File 'lib/graylog2-rails/notifier.rb', line 5 def initialize(args = {}) @gelf = GELF::Notifier.new(Graylog2Rails.["host"], Graylog2Rails.["port"], Graylog2Rails.["max_chunk_size"], { facility: Graylog2Rails.["facility"], level: args.has_key?("level") ? args["level"] : Graylog2Rails.["level"], host: Graylog2Rails.["local_app_name"] }) end |
Instance Attribute Details
#gelf ⇒ Object (readonly)
Returns the value of attribute gelf.
3 4 5 |
# File 'lib/graylog2-rails/notifier.rb', line 3 def gelf @gelf end |
Class Method Details
.notify!(args) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/graylog2-rails/notifier.rb', line 15 def self.notify! args @notifier ||= new = Time.now.utc Rails.logger.tagged("GRAYLOG") do Rails.logger.info "[#{.to_datetime}] #{args.inspect}" end args.merge!({timestamp: .to_f}) @notifier.gelf.notify! args unless Rails.env.development? end |