Class: RailsGraylogger::Notifier
- Inherits:
-
Object
- Object
- RailsGraylogger::Notifier
- Defined in:
- lib/rails-graylogger/notifier.rb
Class Method Summary collapse
Instance Method Summary collapse
- #facility ⇒ Object
-
#initialize ⇒ Notifier
constructor
A new instance of Notifier.
- #notify!(gelf_message) ⇒ Object
- #remote_host ⇒ Object
- #remote_port ⇒ Object
- #sender_host ⇒ Object
Constructor Details
#initialize ⇒ Notifier
Returns a new instance of Notifier.
10 11 12 |
# 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 |
Class Method Details
.notify!(gelf_message) ⇒ Object
4 5 6 7 |
# File 'lib/rails-graylogger/notifier.rb', line 4 def notify!() @@notifier ||= self.new @@notifier.notify!() end |
Instance Method Details
#facility ⇒ Object
22 23 24 |
# File 'lib/rails-graylogger/notifier.rb', line 22 def facility ENV["GRAYLOG_FACILITY"] || "Rails" end |
#notify!(gelf_message) ⇒ Object
30 31 32 33 |
# File 'lib/rails-graylogger/notifier.rb', line 30 def notify!() return if Rails.env == 'test' @gelf_notifier.notify!(.merge(timestamp: Time.now.utc.to_f)) end |
#remote_host ⇒ Object
14 15 16 |
# File 'lib/rails-graylogger/notifier.rb', line 14 def remote_host ENV["GRAYLOG_HOST"] || "127.0.0.1" end |
#remote_port ⇒ Object
18 19 20 |
# File 'lib/rails-graylogger/notifier.rb', line 18 def remote_port ENV["GRAYLOG_PORT"] || 12201 end |
#sender_host ⇒ Object
26 27 28 |
# File 'lib/rails-graylogger/notifier.rb', line 26 def sender_host Socket.gethostname.split(".").first end |