class RailsGraylogger::Notifier
Public Class Methods
new()
click to toggle source
# File lib/rails-graylogger/notifier.rb, line 10 def initialize @gelf_notifier = GELF::Notifier.new(remote_host, remote_port, 1420, facility: facility, host: sender_host) end
notify!(gelf_message)
click to toggle source
# File lib/rails-graylogger/notifier.rb, line 4 def notify!(gelf_message) @@notifier ||= self.new @@notifier.notify!(gelf_message) end
Public Instance Methods
facility()
click to toggle source
# File lib/rails-graylogger/notifier.rb, line 22 def facility ENV["GRAYLOG_FACILITY"] || "Rails" end
notify!(gelf_message)
click to toggle source
# File lib/rails-graylogger/notifier.rb, line 30 def notify!(gelf_message) return if Rails.env == 'test' @gelf_notifier.notify!(gelf_message.merge(timestamp: Time.now.utc.to_f)) end
remote_host()
click to toggle source
# File lib/rails-graylogger/notifier.rb, line 14 def remote_host ENV["GRAYLOG_HOST"] || "127.0.0.1" end
remote_port()
click to toggle source
# File lib/rails-graylogger/notifier.rb, line 18 def remote_port ENV["GRAYLOG_PORT"] || 12201 end
sender_host()
click to toggle source
# File lib/rails-graylogger/notifier.rb, line 26 def sender_host Socket.gethostname.split(".").first end